Change how username is retrieved from SSO
Some checks failed
mirror / mirror (push) Has been skipped
testing / lint-backend (push) Failing after 6m40s
testing / checks-backend (push) Failing after 3m57s
testing / test-unit (push) Has been skipped
testing / test-mysql (push) Has been skipped
testing / test-pgsql (push) Has been skipped
testing / test-sqlite (push) Has been skipped

This commit is contained in:
Anthony Lawn 2024-02-03 09:58:29 -06:00
parent 623f13f2dc
commit 2488750ea4

View file

@ -372,14 +372,15 @@ func handleSignInFull(ctx *context.Context, u *user_model.User, remember, obeyRe
}
func getUserName(gothUser *goth.User) (string, error) {
switch setting.OAuth2Client.Username {
case setting.OAuth2UsernameEmail:
return user_model.NormalizeUserName(strings.Split(gothUser.Email, "@")[0])
case setting.OAuth2UsernameNickname:
return user_model.NormalizeUserName(gothUser.NickName)
default: // OAuth2UsernameUserid
return gothUser.UserID, nil
}
return gothUser.RawData["preferred_username"]
// switch setting.OAuth2Client.Username {
// case setting.OAuth2UsernameEmail:
// return user_model.NormalizeUserName(strings.Split(gothUser.Email, "@")[0])
// case setting.OAuth2UsernameNickname:
// return user_model.NormalizeUserName(gothUser.NickName)
// default: // OAuth2UsernameUserid
// return gothUser.UserID, nil
// }
}
// HandleSignOut resets the session and sets the cookies