public Task <bool> CheckIfUserExists(string email) { Task <IEnumerable <string> > task = auth.FetchProvidersForEmailAsync(email); return(task.ContinueWith(providers => { return providers.Result.Any(); })); }
// Show the providers for the current email address. protected void DisplayProvidersForEmail() { auth.FetchProvidersForEmailAsync(email).ContinueWith(authTask => { if (LogTaskCompletion(authTask, "Fetch Providers")) { DebugLog(string.Format("Email Providers for '{0}':", email)); foreach (string provider in authTask.Result) { DebugLog(provider); } } }); }
private void Test() { var task = auth.FetchProvidersForEmailAsync("").ContinueWith((authTask) => { if (authTask.IsCanceled) { Debug.Log("Provider fetch canceled."); } else if (authTask.IsFaulted) { Debug.Log("Provider fetch encountered an error."); Debug.Log(authTask.Exception.ToString()); } else if (authTask.IsCompleted) { Debug.Log("Email Providers:"); foreach (string provider in authTask.Result) { Debug.Log(provider); } } }); }
/// <summary> /// Unlinks the active auth method from the firebase account /// </summary> /// <returns><c>true</c>, if auth was unlinked, <c>false</c> otherwise.</returns> public static void UnLinkAuth(FirebaseUser requestedUser = null) { if (requestedUser == null) { requestedUser = activeUser; } string linkedAuth = ""; if (auth != null) { ProjectManager.Log("[Firebase Unlink Auth] " + requestedUser.DisplayName); auth.FetchProvidersForEmailAsync(GetEmail(requestedUser)).ContinueWith(task => { if (task.IsCanceled) { Analytics.LogError("Firebase Get Provider", "Fetch providers for email canceled!"); return; } if (task.IsFaulted) { // Firebase for Unity is pretty undocumented for doing more than simply adding the plugins into projects.. // Error handling doesn't seem great either, as of building this there's no error enum or error codes // So we just have strings to work with if we want to do actions on specific errors happening foreach (Exception e in task.Exception.InnerExceptions) { Analytics.LogError("Firebase Get Provider", e.Message); // This string only includes the firebase error, no information about the exception type OnGetProviderFailed(ConvertToAuthError(e.Message)); } return; } if (task.IsCompleted) { linkedAuth = task.Result.ToString(); requestedUser.UnlinkAsync(linkedAuth).ContinueWith(unlinkTask => { if (unlinkTask.IsCanceled) { Analytics.LogError("Firebase Unlink Auth", "UnLinkAuth was canceled!"); return; } if (unlinkTask.IsFaulted) { // Firebase for Unity is pretty undocumented for doing more than simply adding the plugins into projects.. // Error handling doesn't seem great either, as of building this there's no error enum or error codes // So we just have strings to work with if we want to do actions on specific errors happening foreach (Exception e in unlinkTask.Exception.InnerExceptions) { Analytics.LogError("Firebase Unlink Auth", e.Message); // This string only includes the firebase error, no information about the exception type OnUnlinkAuthFailed(ConvertToAuthError(e.Message)); } return; } if (unlinkTask.IsCompleted) { // The auth method is now unlinked from the firebase user reference OnUnlinkAuthSuccessful(); } }); } }); } else { Analytics.LogError("Firebase Unlink Auth", "Auth was null!"); } }