bugfix: use InviteMustGet instead of InviteGet (#653)
This commit is contained in:
parent
5f1c868006
commit
f6b2535cdb
|
@ -25,6 +25,20 @@ func InviteGet(where string, args ...interface{}) (*Invite, error) {
|
|||
return &obj, nil
|
||||
}
|
||||
|
||||
func InviteMustGet(where string, args ...interface{}) (*Invite, error) {
|
||||
var obj Invite
|
||||
has, err := DB["rdb"].Where(where, args...).Get(&obj)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if !has {
|
||||
return nil, fmt.Errorf("invite not found")
|
||||
}
|
||||
|
||||
return &obj, nil
|
||||
}
|
||||
|
||||
func InviteNew(token, creator string) error {
|
||||
now := time.Now().Unix()
|
||||
obj := Invite{
|
||||
|
|
|
@ -320,7 +320,7 @@ func userInvitePost(c *gin.Context) {
|
|||
return err
|
||||
}
|
||||
|
||||
inv, err := models.InviteGet("token=?", f.Token)
|
||||
inv, err := models.InviteMustGet("token=?", f.Token)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue