Fix empty invitation on user creation (#247)

This commit is contained in:
Thomas Miceli 2024-04-04 17:36:18 +02:00 committed by GitHub
parent 572e834999
commit 57273946c3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

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