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.
This commit is contained in:
parent
99489aa920
commit
372b4e5dcd
|
@ -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…
Reference in New Issue