public async Task <FirebaseGoogleAuthResult> SignOut() { await Init(); var module = await authModuleTask.Value; string signOutResult = string.Empty; bool wasUserSignedIn = await IsSignedIn(); try { signOutResult = await module.InvokeAsync <string>("firebaseSignOut"); } catch (Exception e) { Logger.LogError("Sign out failed."); Logger.LogError(e.Message); } FirebaseGoogleAuthResult result = ConvertJsonToAuthResult(signOutResult); if (result.Success && wasUserSignedIn) { base.NotifyAuthenticationStateChanged(GetAuthenticationStateAsync()); } return(result); }
private FirebaseGoogleAuthResult ConvertJsonToAuthResult(string json) { FirebaseGoogleAuthResult authResult; try { authResult = JsonSerializer.Deserialize <FirebaseGoogleAuthResult>( json, new JsonSerializerOptions { PropertyNameCaseInsensitive = true }); } catch (Exception e) { authResult = new FirebaseGoogleAuthResult { Success = false, Error = new FirebaseGoogleAuthResult.GoogleAuthError { message = e.Message } }; } return(authResult); }
private async Task <FirebaseGoogleAuthResult> SignIn( ISet <string> signInScopes, bool signInWithPopup) { var module = await authModuleTask.Value; string signInResult = string.Empty; bool wasUserSignedIn = await IsSignedIn(); string jsMethod = signInWithPopup ? "firebaseSignInWithPopup": "firebaseSignInWithRedirect"; try { signInResult = await module.InvokeAsync <string>(jsMethod, signInScopes); } catch (Exception e) { Logger.LogError("Sign in failed."); Logger.LogError(e.Message); } FirebaseGoogleAuthResult result = ConvertJsonToAuthResult(signInResult); if (result.Success && !wasUserSignedIn) { base.NotifyAuthenticationStateChanged(GetAuthenticationStateAsync()); } return(result); }