Skip to content
Snippets Groups Projects
Commit b085bd27 authored by Cornel Rautenbach's avatar Cornel Rautenbach
Browse files

More auth reusable items

parent 5be47317
No related branches found
Tags v1.266.0
No related merge requests found
......@@ -9,6 +9,21 @@ import (
"google.golang.org/api/idtoken"
)
type AppleAuth struct {
Code string `json:"code"`
IDToken string `json:"id_token"`
State string `json:"state"`
}
type SocialCredentials struct {
Google string `json:"google"`
Apple *AppleAuth `json:"apple"`
}
type LoginResponse struct {
AccessToken string `json:"access_token"`
}
func ValidateGoogleIDToken(tokenString, clientID string) (string, error) {
payload, err := idtoken.Validate(context.Background(), tokenString, clientID)
if err != nil {
......@@ -87,3 +102,7 @@ func ExtractAppleEmailFromIDToken(idToken string) (string, error) {
return string_utils.InterfaceToString(email)
}
func HasSocialCredentials(socialCredentials SocialCredentials) bool {
return socialCredentials.Google != "" || (socialCredentials.Apple != nil && socialCredentials.Apple.IDToken != "" && socialCredentials.Apple.Code != "")
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment