public void TestBadIdentifyRequest() { var request = new IdentityRequest(); request.ClientSdk = new ClientSdk(); request.ClientSdk.Platform = Platform.Xbox; request.ClientSdk.SdkVendor = "foo vendor"; request.ClientSdk.SdkVersion = "foo version"; request.Context = "foo context"; request.Environment = Dto.Identity.Environment.Production; request.KnownIdentities = new Identities(); request.RequestId = "foo request id"; request.RequestTimestampMs = 1234; request.SourceRequestId = "foo source request id"; var client = new IdentityApiClient(ApiKey, ApiSecret); var task = client.Identify(request); task.Wait(); var response = task.Result; Assert.IsNotNull(response); Assert.AreEqual(typeof(ErrorResponse), response.GetType()); Assert.AreEqual(((ErrorResponse)response).StatusCode, 400); }
public void TestIdentifyRequest() { var request = new IdentityRequest(); request.ClientSdk = new ClientSdk(); request.ClientSdk.Platform = Platform.Xbox; request.ClientSdk.SdkVendor = "foo vendor"; request.ClientSdk.SdkVersion = "foo version"; request.Context = "foo context"; request.Environment = Dto.Identity.Environment.Development; request.KnownIdentities = new Identities(); request.KnownIdentities.Add(IdentityType.DeviceApplicationStamp, Guid.NewGuid().ToString()); request.RequestId = "foo request id"; request.RequestTimestampMs = 1234; request.SourceRequestId = "foo source request id"; var client = new IdentityApiClient(ApiKey, ApiSecret); var task = client.Identify(request); task.Wait(); var response = task.Result; Assert.IsNotNull(response); Assert.AreEqual(typeof(IdentityResponse), response.GetType()); Assert.IsNotNull(((IdentityResponse)response).Mpid); }
internal IdentityApi(string apiKey, string apiSecret, PersistenceManager persistenceManager) { this.persistenceManager = persistenceManager; this.identityApiManager = new IdentityApiClient(apiKey, apiSecret); this.identityApiManager.UserAgent = MParticle.UserAgent; this.GenerateDasIfNeeded(); }
protected override async Task OnInitializedAsync() { try { ApplicationUserService = ScopedServices.GetRequiredService <IApplicationUserService>(); var userId = NavigationManager.GetQueryValue("userId"); var code = NavigationManager.GetQueryValue("code"); var email = NavigationManager.GetQueryValue("email"); if (userId == null || email == null || code == null) { SetWrongParameters("Wrong code", "This code is not valid."); SetInitialized(); return; } var user = await UserManager.FindByIdAsync(userId); if (user == null) { SetWrongParameters("User not found", "Unable to load user."); SetInitialized(); return; } code = Encoding.UTF8.GetString(WebEncoders.Base64UrlDecode(code)); try { await ApplicationUserService.ConfirmEmailChangeAsync(new UserConfirmEmailChangeModel() { UserId = userId, Email = email, Code = code }); await IdentityApiClient.LogoutAsync(); } catch (Exception ex) { SetWrongParameters("Error changing email", ex.Message); SetInitialized(); return; } Success = true; SetInitialized(); } catch (Exception ex) { Logger.LogError(ex.Message); SetLoadFailed(ex.Message); } }
private async Task UpdateProfileInfoAsync() { try { await ButtonUpdateProfile.SpinAsync(async() => { await ApplicationUserService.UpdateProfileInfoAsync(UserProfileModel); await IdentityApiClient.RefreshSignInAsync(); await ToastService.ShowToastAsync("Your profile has been updated.", ToastType.Success); }); } catch (Exception ex) { Logger.LogError(ex.Message); await ToastService.ShowToastAsync(ex.Message, ToastType.Error); } }
private async Task SignInWithSecurityKeyAsync() { try { AuthenticationStep = AuthenticationStep.SecurityKeyAuthentication; SecurityKeySignInModel.AuthenticatorAssertionRawResponse = await Fido2Service.MakeAssertionRawResponse(UserEmailModel.Email, JSRuntime); var response = await IdentityApiClient.LoginWithFido2Async(SecurityKeySignInModel); response.ThrowIfFailed(); NavigationManager.NavigateTo(ReturnUrl, true); } catch (Exception ex) { Logger.LogError(ex.Message); AuthenticationStep = AuthenticationStep.SecurityKeyError; } }
private async Task ChangePasswordAsync() { try { await ButtonChangePassword.SpinAsync(async() => { await ApplicationUserService.UpdateAccountPasswordAsync(ChangePasswordModel); await IdentityApiClient.RefreshSignInAsync(); await ToastService.ShowToastAsync("Password updated.", ToastType.Success); ChangePasswordModel = new ChangePasswordModel() { UserId = CurrentUser.Id }; }); } catch (Exception ex) { Logger.LogError(ex.Message); await ToastService.ShowToastAsync(ex.Message, ToastType.Error); } }
private async Task LoginWithPasswordAsync() { try { await ButtonSpinner.SpinAsync(async() => { var response = await IdentityApiClient.LoginWithPasswordAsync(PasswordSignInModel); response.ThrowIfFailed(); if (response.Succeeded) { NavigationManager.NavigateTo(Routes.Dashboard, true); return; } if (response.RequiresTwoFactor) { NavigationManager.NavigateTo($"{Routes.LoginWith2Fa}?returnUrl={ReturnUrl}", true); return; } if (response.IsLockedOut) { NavigationManager.NavigateTo(Routes.Lockout, true); return; } }); } catch (HESException ex) when(ex.Code == HESCode.InvalidLoginAttempt) { ValidationErrorMessage.DisplayError(nameof(PasswordSignInModel.Password), HESException.GetMessage(ex.Code)); } catch (Exception ex) { Logger.LogError(ex.Message); SetErrorMessage(ex.Message); } }