Browse Source

Fix nil pointer when navigating to bad invite URL

Previously when looking up an invite ID that doesn't exist, the database
call wouldn't communicate its non-existence in a standard way --
returning a nil object and nil error. Now the database call returns a
404 error, so handlers can show the correct page.
pull/81/head
Matt Baer 5 years ago
parent
commit
372b4e5dcd
1 changed files with 1 additions and 1 deletions
  1. +1
    -1
      database.go

+ 1
- 1
database.go View File

@@ -2234,7 +2234,7 @@ func (db *datastore) GetUserInvite(id string) (*Invite, error) {
err := db.QueryRow("SELECT id, max_uses, created, expires, inactive FROM userinvites WHERE id = ?", id).Scan(&i.ID, &i.MaxUses, &i.Created, &i.Expires, &i.Inactive)
switch {
case err == sql.ErrNoRows:
return nil, nil
return nil, impart.HTTPError{http.StatusNotFound, "Invite doesn't exist."}
case err != nil:
log.Error("Failed selecting invite: %v", err)
return nil, err


Loading…
Cancel
Save