Skip to content

Commit

Permalink
fix: skip invite code in verify email
Browse files Browse the repository at this point in the history
  • Loading branch information
JingYiJun committed Apr 9, 2024
1 parent 3bb690e commit 6e5a7db
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions apis/account/account.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ func Register(c *fiber.Ctx) error {
user.UpdateIP(remoteIP)
user.ShareConsent = true
// set invite code
if configObject.InviteRequired {
if inviteRequired {
user.InviteCode = inviteCode.Code
}
err = DB.Save(&user).Error
Expand All @@ -156,7 +156,7 @@ func Register(c *fiber.Ctx) error {
user.ShareConsent = true

// set invite code
if configObject.InviteRequired {
if inviteRequired {
user.InviteCode = inviteCode.Code
}

Expand Down Expand Up @@ -185,7 +185,7 @@ func Register(c *fiber.Ctx) error {
}

// update inviteCode
if configObject.InviteRequired {
if inviteRequired {
inviteCode.IsActivated = true
DB.Save(&inviteCode)
}
Expand Down Expand Up @@ -371,7 +371,15 @@ func VerifyWithEmail(c *fiber.Ctx) error {

if scope == "register" {
// check Invite code
if configObject.InviteRequired {
inviteRequired := configObject.InviteRequired
// check email suffix in no need invite code
for _, emailSuffix := range config.Config.NoNeedInviteCodeEmailSuffix {
if strings.HasSuffix(query.Email, emailSuffix) {
inviteRequired = false
break
}
}
if inviteRequired {
if query.InviteCode == nil {
return errCollection.ErrNeedInviteCode
}
Expand Down

0 comments on commit 6e5a7db

Please sign in to comment.