Compare commits
3 Commits
0.32.0-bet
...
0.32.0-bet
Author | SHA1 | Date | |
---|---|---|---|
![]() |
c9ba0b13f8 | ||
![]() |
fadd9f6168 | ||
![]() |
395e2e2a85 |
@@ -482,15 +482,29 @@ func processAppleUserInfo(code string) (models.User, error) {
|
|||||||
}
|
}
|
||||||
fmt.Println("=> decoded claims data", decodedClaimsData)
|
fmt.Println("=> decoded claims data", decodedClaimsData)
|
||||||
|
|
||||||
claims := map[string]string{}
|
claims := make(map[string]interface{})
|
||||||
err = json.Unmarshal([]byte(decodedClaimsData), &claims)
|
err = json.Unmarshal([]byte(decodedClaimsData), &claims)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Debug("Failed to unmarshal claims data: ", err)
|
log.Debug("Failed to unmarshal claims data: ", err)
|
||||||
return user, fmt.Errorf("failed to unmarshal claims data: %s", err.Error())
|
return user, fmt.Errorf("failed to unmarshal claims data: %s", err.Error())
|
||||||
}
|
}
|
||||||
fmt.Println("=> claims map:", claims)
|
|
||||||
email := claims["email"]
|
fmt.Println("=> claims", claims)
|
||||||
user.Email = email
|
|
||||||
|
if val, ok := claims["email"]; !ok {
|
||||||
|
log.Debug("Failed to extract email from claims.")
|
||||||
|
return user, fmt.Errorf("unable to extract email, please check the scopes enabled for your app. It needs `email`, `name` scopes")
|
||||||
|
} else {
|
||||||
|
user.Email = val.(string)
|
||||||
|
}
|
||||||
|
|
||||||
|
if val, ok := claims["name"]; ok {
|
||||||
|
nameData := val.(map[string]interface{})
|
||||||
|
givenName := nameData["firstName"].(string)
|
||||||
|
familyName := nameData["lastName"].(string)
|
||||||
|
user.GivenName = &givenName
|
||||||
|
user.FamilyName = &familyName
|
||||||
|
}
|
||||||
|
|
||||||
return user, err
|
return user, err
|
||||||
}
|
}
|
||||||
|
@@ -184,7 +184,8 @@ func OAuthLoginHandler() gin.HandlerFunc {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
oauth.OAuthProviders.AppleConfig.RedirectURL = hostname + "/oauth_callback/" + constants.SignupMethodApple
|
oauth.OAuthProviders.AppleConfig.RedirectURL = hostname + "/oauth_callback/" + constants.SignupMethodApple
|
||||||
url := oauth.OAuthProviders.AppleConfig.AuthCodeURL(oauthStateString, oauth2.SetAuthURLParam("response_mode", "form_post"))
|
// Scope from the root config was not passed for apple login
|
||||||
|
url := oauth.OAuthProviders.AppleConfig.AuthCodeURL(oauthStateString, oauth2.SetAuthURLParam("response_mode", "form_post"), oauth2.SetAuthURLParam("scope", "name email"))
|
||||||
c.Redirect(http.StatusTemporaryRedirect, url)
|
c.Redirect(http.StatusTemporaryRedirect, url)
|
||||||
default:
|
default:
|
||||||
log.Debug("Invalid oauth provider: ", provider)
|
log.Debug("Invalid oauth provider: ", provider)
|
||||||
|
@@ -130,7 +130,6 @@ func InitOAuth() error {
|
|||||||
AuthURL: "https://appleid.apple.com/auth/authorize",
|
AuthURL: "https://appleid.apple.com/auth/authorize",
|
||||||
TokenURL: "https://appleid.apple.com/auth/token",
|
TokenURL: "https://appleid.apple.com/auth/token",
|
||||||
},
|
},
|
||||||
Scopes: []string{"email"},
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user