Use OAuth avatar to update default avatar.

This commit is contained in:
Yang Luo
2021-06-21 00:54:07 +08:00
parent 68018c6d12
commit 54e97d57bf
2 changed files with 5 additions and 4 deletions

View File

@ -104,7 +104,7 @@ func setUserProperty(user *User, field string, value string) {
}
}
func SetUserOAuthProperties(user *User, providerType string, userInfo *idp.UserInfo) bool {
func SetUserOAuthProperties(organization *Organization, user *User, providerType string, userInfo *idp.UserInfo) bool {
if userInfo.Id != "" {
propertyName := fmt.Sprintf("oauth_%s_id", providerType)
setUserProperty(user, propertyName, userInfo.Id)
@ -130,7 +130,7 @@ func SetUserOAuthProperties(user *User, providerType string, userInfo *idp.UserI
if userInfo.AvatarUrl != "" {
propertyName := fmt.Sprintf("oauth_%s_avatarUrl", providerType)
setUserProperty(user, propertyName, userInfo.AvatarUrl)
if user.Avatar == "" {
if user.Avatar == "" || user.Avatar == organization.DefaultAvatar {
user.Avatar = userInfo.AvatarUrl
}
}