diff --git a/auth/social_login.go b/auth/social_login.go index e3d770eadb254db6c9e85d350de0379896c73970..1d65373864cbbb8722c0cba8f949404e7c65fb66 100644 --- a/auth/social_login.go +++ b/auth/social_login.go @@ -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 != "") +}