bugfix: use InviteMustGet instead of InviteGet (#653)

This commit is contained in:
yubo 2021-04-14 12:48:26 +08:00 committed by GitHub
parent 5f1c868006
commit f6b2535cdb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 1 deletions

View File

@ -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{

View File

@ -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
}