Skip to content

Commit

Permalink
Fix empty invitation on user creation (thomiceli#247)
Browse files Browse the repository at this point in the history
  • Loading branch information
thomiceli committed Apr 4, 2024
1 parent 572e834 commit 5727394
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions internal/web/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ func processRegister(ctx echo.Context) error {
invitation, err := db.GetInvitationByCode(code)
if err != nil && !errors.Is(err, gorm.ErrRecordNotFound) {
return errorRes(500, "Cannot check for invitation code", err)
} else if invitation != nil && invitation.IsUsable() {
} else if invitation.ID != 0 && invitation.IsUsable() {
disableSignup = false
}

Expand Down Expand Up @@ -113,8 +113,10 @@ func processRegister(ctx echo.Context) error {
}
}

if err := invitation.Use(); err != nil {
return errorRes(500, "Cannot use invitation", err)
if invitation.ID != 0 {
if err := invitation.Use(); err != nil {
return errorRes(500, "Cannot use invitation", err)
}
}

sess.Values["user"] = user.ID
Expand Down

0 comments on commit 5727394

Please sign in to comment.