async Task ProcessLogin(string returnUrl) { this.AuthenticationState.ReturnUrl = returnUrl; RemoteAuthenticationResult <TAuthenticationState> result = await this.AuthenticationService.SignInAsync(new AppServiceAuthRemoteAuthenticationContext <TAuthenticationState> { State = AuthenticationState, SelectedProvider = SelectedOption }); switch (result.Status) { case RemoteAuthenticationStatus.Redirect: break; case RemoteAuthenticationStatus.Success: await this.OnLogInSucceeded.InvokeAsync(result.State); await this.NavigateToReturnUrl(this.GetReturnUrl(result.State, returnUrl)); break; case RemoteAuthenticationStatus.Failure: this.message = result.ErrorMessage; this.Navigation.NavigateTo(this.ApplicationPaths.LogInFailedPath); break; case RemoteAuthenticationStatus.OperationCompleted: break; default: break; } }
private async Task UpdateUserOnSuccess(RemoteAuthenticationResult <TRemoteAuthenticationState> result) { if (result.Status == RemoteAuthenticationStatus.Success) { var getUserTask = GetUser(); await getUserTask; UpdateUser(getUserTask); } }
protected async override Task OnParametersSetAsync() { switch (this.Action) { case RemoteAuthenticationActions.LogIn: if (this.SelectedOption != null) { await this.ProcessLogin(this.GetReturnUrl(state : null)); } return; // Doing this because the SignOutManager intercepts the call otherwise and it'll fail // TODO: Investigate a custom SignOutManager case RemoteAuthenticationActions.LogOut: RemoteAuthenticationResult <TAuthenticationState> result = await this.AuthenticationService.SignOutAsync(new AppServiceAuthRemoteAuthenticationContext <TAuthenticationState> { State = AuthenticationState }); switch (result.Status) { case RemoteAuthenticationStatus.Redirect: break; case RemoteAuthenticationStatus.Success: await this.OnLogOutSucceeded.InvokeAsync(result.State); await this.NavigateToReturnUrl(this.GetReturnUrl(this.AuthenticationState)); break; case RemoteAuthenticationStatus.OperationCompleted: break; case RemoteAuthenticationStatus.Failure: this.Navigation.NavigateTo(this.ApplicationPaths.LogOutFailedPath); break; default: throw new InvalidOperationException($"Invalid authentication result status."); } break; default: await base.OnParametersSetAsync(); break; } }
public RemoteAuthenticationResult <TRemoteAuthenticationState> Convert() { var result = new RemoteAuthenticationResult <TRemoteAuthenticationState>(); result.ErrorMessage = ErrorMessage; result.State = State; if (Status != null && Enum.TryParse <RemoteAuthenticationStatus>(Status, ignoreCase: true, out var status)) { result.Status = status; } else { throw new InvalidOperationException($"Can't convert status '${Status ?? "(null)"}'."); } return(result); }