Fix bug with missing roles after password reset

This commit is contained in:
Denis Arh
2021-03-20 17:45:11 +01:00
parent 4ffe124f98
commit 02ebffd125
+8 -9
View File
@@ -3,7 +3,6 @@ package service
import (
"context"
"fmt"
rand2 "math/rand"
"regexp"
"strconv"
@@ -677,14 +676,14 @@ func (svc auth) loadFromTokenAndConfirmEmail(ctx context.Context, token, tokenTy
aam.setUser(u)
ctx = internalAuth.SetIdentityToContext(ctx, u)
if u.EmailConfirmed {
return nil
}
u.EmailConfirmed = true
u.UpdatedAt = now()
if err = store.UpdateUser(ctx, svc.store, u); err != nil {
return err
if !u.EmailConfirmed {
// User's email is not confirmed but going through password reset flow
// we can confirm it
u.EmailConfirmed = true
u.UpdatedAt = now()
if err = store.UpdateUser(ctx, svc.store, u); err != nil {
return err
}
}
if err = svc.LoadRoleMemberships(ctx, u); err != nil {