mirror of
https://github.com/writefreely/writefreely
synced 2024-11-24 09:33:11 +00:00
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
1 changed files with 1 additions and 1 deletions
|
@ -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 a new issue