Пример #1
0
        public async Task <IUser> UnlinkAsync(string providerId)
        {
            try
            {
                var result = await _user.UnlinkAsync(providerId).ConfigureAwait(false);

                return(new UserWrapper(result.User));
            }
            catch (FirebaseException e)
            {
                throw ExceptionMapper.Map(e);
            }
        }
 public Task UnlinkAsync(string providerId)
 {
     return(_wrapped.UnlinkAsync(providerId));
 }
Пример #3
0
    /// <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!");
        }
    }