[#276] added option to list and unlink external user auth relations

This commit is contained in:
Gani Georgiev
2022-09-01 12:22:59 +03:00
parent f61d0ec6f7
commit f0b57c6b91
7 changed files with 240 additions and 118 deletions
+9 -8
View File
@@ -152,14 +152,6 @@ func (form *UserOauth2Login) Submit() (*models.User, *auth.AuthUser, error) {
return err
}
} else {
// update the existing user verified state
if !user.Verified {
user.Verified = true
if err := txDao.SaveUser(user); err != nil {
return err
}
}
// update the existing user empty email if the authData has one
// (this in case previously the user was created with
// an OAuth2 provider that didn't return an email address)
@@ -169,6 +161,15 @@ func (form *UserOauth2Login) Submit() (*models.User, *auth.AuthUser, error) {
return err
}
}
// update the existing user verified state
// (only if the user doesn't have an email or the user email match with the one in authData)
if !user.Verified && (user.Email == "" || user.Email == authData.Email) {
user.Verified = true
if err := txDao.SaveUser(user); err != nil {
return err
}
}
}
// create ExternalAuth relation if missing