void IIdSiteSyncResultListener.OnRegistered(IAccountResult result) { if (this.onRegistered != null) { this.onRegistered(result); } }
void IIdSiteSyncResultListener.OnAuthenticated(IAccountResult result) { if (this.onAuthenticated != null) { this.onAuthenticated(result); } }
void IIdSiteSyncResultListener.OnLogout(IAccountResult result) { if (this.onLogout != null) { this.onLogout(result); } }
private void AddErrors(IAccountResult result) { foreach (var error in result.Errors) { ModelState.AddModelError(string.Empty, error); } }
void IIdSiteSyncResultListener.OnRegistered(IAccountResult result) { if (this.onRegistered != null) { this.onRegistered(result); } }
void IIdSiteSyncResultListener.OnAuthenticated(IAccountResult result) { if (this.onAuthenticated != null) { this.onAuthenticated(result); } }
void IIdSiteSyncResultListener.OnLogout(IAccountResult result) { if (this.onLogout != null) { this.onLogout(result); } }
public IAccountResult ActivateAccount(string userId, int accountId) { var sql = "UPDATE Accounts SET IsActive = 0 WHERE UserID = {0} AND AccountId = {1}"; IAccountResult accountResult = null; using (var conn = _connectionFactory.GetConnection()) { var result = conn.Execute(string.Format(sql, userId, accountId)); accountResult = new AccountSuccessResult(); accountResult.AddData(string.Format("{0} account(s) activated.", result)); } return(accountResult); }
private Task DispatchResponseStatusAsync(IdSiteResultStatus status, IAccountResult accountResult, CancellationToken cancellationToken) { if (status == IdSiteResultStatus.Registered) { return(this.resultListener.OnRegisteredAsync(accountResult, cancellationToken)); } else if (status == IdSiteResultStatus.Authenticated) { return(this.resultListener.OnAuthenticatedAsync(accountResult, cancellationToken)); } else if (status == IdSiteResultStatus.Logout) { return(this.resultListener.OnLogoutAsync(accountResult, cancellationToken)); } throw new ArgumentException($"Encountered unknown ID Site result status: {status}"); }
private void DispatchResponseStatus(IdSiteResultStatus status, IAccountResult accountResult) { if (status == IdSiteResultStatus.Registered) { this.resultListener.OnRegistered(accountResult); return; } else if (status == IdSiteResultStatus.Authenticated) { this.resultListener.OnAuthenticated(accountResult); return; } else if (status == IdSiteResultStatus.Logout) { this.resultListener.OnLogout(accountResult); return; } throw new ArgumentException($"Encountered unknown ID Site result status: {status}"); }
private void DispatchResponseStatus(IdSiteResultStatus status, IAccountResult accountResult) { if (status == IdSiteResultStatus.Registered) { this.resultListener.OnRegistered(accountResult); return; } else if (status == IdSiteResultStatus.Authenticated) { this.resultListener.OnAuthenticated(accountResult); return; } else if (status == IdSiteResultStatus.Logout) { this.resultListener.OnLogout(accountResult); return; } throw new ArgumentException($"Encountered unknown ID Site result status: {status}"); }
Task IIdSiteAsyncResultListener.OnRegisteredAsync(IAccountResult result, CancellationToken cancellationToken) { return this.onRegistered != null ? this.onRegistered(result, cancellationToken) : Task.FromResult(true); }
public void Handle_response(string id_, string jwtResponse, string expectedStatus, bool isNewAccount, string expectedState) { IAccountResult accountResultFromListener = null; var listener = new InlineIdSiteSyncResultListener( onAuthenticated: result => { if (expectedStatus == IdSiteResultStatus.Authenticated) { accountResultFromListener = result; } else { throw new InvalidOperationException("This method should not have been executed"); } }, onLogout: result => { if (expectedStatus == IdSiteResultStatus.Logout) { accountResultFromListener = result; } else { throw new InvalidOperationException("This method should not have been executed"); } }, onRegistered: result => { if (expectedStatus == IdSiteResultStatus.Registered) { accountResultFromListener = result; } else { throw new InvalidOperationException("This method should not have been executed"); } }); var testApiKey = ClientApiKeys.Builder().SetId("2EV70AHRTYF0JOA7OEFO3SM29").SetSecret("goPUHQMkS4dlKwl5wtbNd91I+UrRehCsEDJrIrMruK8").Build(); var fakeRequestExecutor = Substitute.For <IRequestExecutor>(); fakeRequestExecutor.ApiKey.Returns(testApiKey); this.dataStore = TestDataStore.Create(fakeRequestExecutor, Caches.NewInMemoryCacheProvider().Build()); var request = new DefaultHttpRequest(HttpMethod.Get, new CanonicalUri($"https://foo.bar?{IdSiteClaims.JwtResponse}={jwtResponse}")); IIdSiteSyncCallbackHandler callbackHandler = new DefaultIdSiteSyncCallbackHandler(this.dataStore, request); callbackHandler.SetResultListener(listener); var accountResult = callbackHandler.GetAccountResult(); // Validate result (accountResult as DefaultAccountResult).Account.Href.ShouldBe("https://api.stormpath.com/v1/accounts/7Ora8KfVDEIQP38KzrYdAs"); (accountResultFromListener as DefaultAccountResult).Account.Href.ShouldBe("https://api.stormpath.com/v1/accounts/7Ora8KfVDEIQP38KzrYdAs"); accountResult.IsNewAccount.ShouldBe(isNewAccount); accountResultFromListener.IsNewAccount.ShouldBe(isNewAccount); accountResult.State.ShouldBe(expectedState); accountResultFromListener.State.ShouldBe(expectedState); var expectedResultStatus = IdSiteResultStatus.Parse(expectedStatus); accountResult.Status.ShouldBe(expectedResultStatus); accountResultFromListener.Status.ShouldBe(expectedResultStatus); }
Task IIdSiteAsyncResultListener.OnRegisteredAsync(IAccountResult result, CancellationToken cancellationToken) { return(this.onRegistered != null ? this.onRegistered(result, cancellationToken) : Task.FromResult(true)); }
Task IIdSiteAsyncResultListener.OnLogoutAsync(IAccountResult result, CancellationToken cancellationToken) { return(this.onLogout != null ? this.onLogout(result, cancellationToken) : Task.FromResult(true)); }
private Task DispatchResponseStatusAsync(IdSiteResultStatus status, IAccountResult accountResult, CancellationToken cancellationToken) { if (status == IdSiteResultStatus.Registered) { return this.resultListener.OnRegisteredAsync(accountResult, cancellationToken); } else if (status == IdSiteResultStatus.Authenticated) { return this.resultListener.OnAuthenticatedAsync(accountResult, cancellationToken); } else if (status == IdSiteResultStatus.Logout) { return this.resultListener.OnLogoutAsync(accountResult, cancellationToken); } throw new ArgumentException($"Encountered unknown ID Site result status: {status}"); }
Task IIdSiteAsyncResultListener.OnLogoutAsync(IAccountResult result, CancellationToken cancellationToken) { return this.onLogout != null ? this.onLogout(result, cancellationToken) : Task.FromResult(true); }
/// <summary> /// Synchronously returns the user account that either logged in or was created as a result of registration on the ID Site. /// You can determine if the account is newly registered if <see cref="IAccountResult.IsNewAccount"/> is <see langword="true"/>. /// If <see cref="IAccountResult.IsNewAccount"/> is <see langword="false"/>, the account reflects a previously-registered user /// that has logged in. /// </summary> /// <param name="source">The account result.</param> /// <returns>The user's <see cref="IAccount">Account</see> resource.</returns> /// <exception cref="System.ApplicationException">The account is not present.</exception> public static IAccount GetAccount(this IAccountResult source) => (source as IAccountResultSync).GetAccount();