public void AddGoogle(GoogleIdentity identity, string name) { var now = DateTime.UtcNow; _identities.Add(new GoogleIdentityModel(identity.Value, name, now)); UpdatedAt = now; }
public async Task Login_NewUser_ReturnsNull() { User user = null; userRepository.Setup(x => x.GetUserByEmail(Dto.EmailType.GOOGLE, loginData.Email)).Returns(user); var googleIdentity = new GoogleIdentity(jwtFactory.Object, userRepository.Object); Assert.IsNull(await googleIdentity.Login(loginData)); }
public GoogleAccount(GoogleIdentity identity, EmailIdentity email, bool isEmailVerified, string?firstName, string?lastName, Uri?picture, CultureInfo?locale) { Identity = identity; Email = email; IsEmailVerified = isEmailVerified; FirstName = firstName; LastName = lastName; Picture = picture; Locale = locale; }
private static GoogleIdentity get() { if (_googleIdentity == null) { GameObject go = new GameObject(); go.AddComponent <GoogleIdentity>(); _googleIdentity = go.GetComponent <GoogleIdentity>(); } return(_googleIdentity); }
public static void AttachIdentityGooglePlay() { #if UNITY_ANDROID GameObject dialogObject = new GameObject("Dialog"); AttachIdentityDialog dialog = dialogObject.AddComponent <AttachIdentityDialog>(); dialog.m_exampleAccountType = ExampleAccountType.GooglePlay; GoogleIdentity.RefreshGoogleIdentity(identity => { BrainCloudWrapper.Client.IdentityService.AttachGoogleIdentity(identity.GoogleId, identity.GoogleToken, dialog.OnSuccess_AttachIndentity, dialog.OnError_AttachIdentity); }); #else ErrorDialog.DisplayErrorDialog("AuthenticateAsGooglePlay", "You can only use GooglePlay auth on Android Devices"); #endif }
public static void AuthenticateAsGooglePlay(bool forceCreate = false) { #if UNITY_ANDROID GameObject dialogObject = new GameObject("Dialog"); AuthenticateDialog dialog = dialogObject.AddComponent <AuthenticateDialog>(); dialog.m_exampleAccountType = ExampleAccountType.GooglePlay; GoogleIdentity.RefreshGoogleIdentity(identity => { App.Bc.AuthenticateGoogle(identity.GoogleId, identity.GoogleToken, forceCreate, dialog.OnSuccess_Authenticate, dialog.OnError_Authenticate); }); #else ErrorDialog.DisplayErrorDialog("AuthenticateAsGooglePlay", "You can only use GooglePlay auth on Android Devices"); #endif }
public static void DetachIdentityGooglePlay(bool contiuneAsAnonymous = false) { #if UNITY_ANDROID GameObject dialogObject = new GameObject("Dialog"); DetachIdentityDialog dialog = dialogObject.AddComponent <DetachIdentityDialog>(); dialog.m_exampleAccountType = ExampleAccountType.GooglePlay; GoogleIdentity.RefreshGoogleIdentity(identity => { App.Bc.Client.IdentityService.DetachGoogleIdentity(identity.GoogleId, contiuneAsAnonymous, dialog.OnSuccess_DetachIdentity, dialog.OnError_DetachIdentity); }); #else ErrorDialog.DisplayErrorDialog("AuthenticateAsGooglePlay", "You can only use GooglePlay auth on Android Devices"); #endif }
public void Display() { GUILayout.BeginHorizontal(); GUILayout.Label("anonId: " + App.Bc.Client.AuthenticationService.AnonymousId); GUILayout.Label("profileId: " + App.Bc.Client.AuthenticationService.ProfileId); GUILayout.EndHorizontal(); #if UNITY_ANDROID GUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); GUILayout.Label("googleToken: " + GoogleIdentity.GetGoogleToken()); GUILayout.EndHorizontal(); #endif }
public async Task Login_VerifiedUser_ReturnsNotNull() { string token = "token"; User user = new User { Id = "1", UserName = loginData.Email, Email = loginData.Email, GoogleVerified = true }; userRepository.Setup(x => x.GetUserByEmail(Dto.EmailType.GOOGLE, loginData.Email)).Returns(user); userRepository.Setup(x => x.GetUserByEmail(Dto.EmailType.LOGIN, loginData.Email)).Returns(user); jwtFactory.Setup(x => x.GenerateEncodedToken(loginData.Email, It.IsAny <ClaimsIdentity>())).Returns(Task.FromResult(token)); var googleIdentity = new GoogleIdentity(jwtFactory.Object, userRepository.Object); Assert.AreEqual(await googleIdentity.Login(loginData), token); }