From 57273946c33489577f59bfefcae7a3d50cb4c35f Mon Sep 17 00:00:00 2001 From: Thomas Miceli <27960254+thomiceli@users.noreply.github.com> Date: Thu, 4 Apr 2024 17:36:18 +0200 Subject: [PATCH] Fix empty invitation on user creation (#247) --- internal/web/auth.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/internal/web/auth.go b/internal/web/auth.go index 82a1a4b..122d677 100644 --- a/internal/web/auth.go +++ b/internal/web/auth.go @@ -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