Пример #1
0
 public async Task SendEmailVerificationAsync()
 {
     try
     {
         await _user.SendEmailVerificationAsync(null).ConfigureAwait(false);
     }
     catch (FirebaseException e)
     {
         throw ExceptionMapper.Map(e);
     }
 }
Пример #2
0
    // 회원가입 버튼을 눌렀을 때 작동할 함수.
    public void SignUp()
    {
        string email    = emailInput.text;
        string password = passInput.text;

        auth = Firebase.Auth.FirebaseAuth.DefaultInstance;

        if (string.IsNullOrEmpty(email) || string.IsNullOrEmpty(password))
        {
            resultText.text = "빈칸이 존재합니다.";
            return;
        }
        else if (password.Equals(passConfirm.text) == false)
        {
            resultText.text = "비밀번호를 확인하세요";
            return;
        }

        auth.CreateUserWithEmailAndPasswordAsync(email, password).ContinueWith(task =>  // auth 객체를 이용해서 Email, Password 비동기식 생성.
        {
            if (task.IsFaulted)
            {
                resultText.text = "동일한 메일이 존재합니다";
            }
            else
            {
                FirebaseUser user = task.Result;
                user.SendEmailVerificationAsync().ContinueWith(t =>       // user 객체를 이용해서 Email Verification 메일을 보낸다.
                {
                    resultText.text = "확인 메일 전송";
                });
            }
        });
    }
Пример #3
0
    /// <summary>
    /// Sends a verification email to the email the user registered with, you can call IsEmailVerified() to check if the user has verified their email
    /// </summary>
    /// <returns><c>true</c>, if firebase verification email was sent, <c>false</c> otherwise.</returns>
    /// <param name="requestedUser">Requested user.</param>
    public static void FirebaseSendEmailVerification(FirebaseUser requestedUser = null)
    {
        if (requestedUser == null)
        {
            requestedUser = activeUser;
        }

        if (requestedUser != null)
        {
            ProjectManager.Log("[Firebase Email Verify Send] " + requestedUser.DisplayName);

            if (!string.IsNullOrEmpty(requestedUser.Email))
            {
                requestedUser.SendEmailVerificationAsync().ContinueWith(task => {
                    if (task.IsCanceled)
                    {
                        Analytics.LogError("Firebase Email Verify Send", "Send email verification 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 Email Verify Send", e.Message);                                     // This string only includes the firebase error, no information about the exception type

                            OnSendEmailVerificationFailed(ConvertToAuthError(e.Message));
                        }
                        return;
                    }

                    if (task.IsCompleted)
                    {
                        // Firebase email verification sent successfully

                        OnSendEmailVerificationSuccessful();
                    }
                });
            }
            else
            {
                Analytics.LogError("Firebase Email Verify Send", "User did not have an email address");

                                        #if twitter
                ProjectManager.Log("If this is a twitter user make sure the twitter app has permission to get email addresses!");
                                        #endif
            }
        }
        else
        {
            Analytics.LogError("Firebase Email Verify Send", "User was null!");
        }
    }
    public void Signup(string email, string password)
    {
        if (string.IsNullOrEmpty(email) || string.IsNullOrEmpty(password))
        {
            //Error handling
            return;
        }

        auth.CreateUserWithEmailAndPasswordAsync(email, password).ContinueWith(task =>
        {
            if (task.IsCanceled)
            {
                Debug.LogError("CreateUserWithEmailAndPasswordAsync was canceled.");
                return;
            }
            if (task.IsFaulted)
            {
                Debug.LogError("CreateUserWithEmailAndPasswordAsync error: " + task.Exception);
                if (task.Exception.InnerExceptions.Count > 0)
                {
                    UpdateErrorMessage(task.Exception.InnerExceptions[0].Message);
                }
                return;
            }

            FirebaseUser newUser = task.Result;                     // Firebase user has been created.
            Debug.LogFormat("Firebase user created successfully: {0} ({1})",
                            newUser.DisplayName, newUser.UserId);

            newUser.SendEmailVerificationAsync().ContinueWith(ntask => {
                if (ntask.IsCanceled)
                {
                    Debug.LogError("SendEmailVerificationAsync was canceled.");
                    return;
                }
                if (ntask.IsFaulted)
                {
                    Debug.LogError("SendEmailVerificationAsync encountered an error: " + task.Exception);
                    return;
                }

                Debug.Log("Email sent successfully.");
            });
            UpdateErrorMessage("Signup Success");
        });
    }
Пример #5
0
    public void ResendVerificationEmail()
    {
        FirebaseUser newUser = auth.CurrentUser;

        newUser.SendEmailVerificationAsync().ContinueWith(emailTask =>
        {
            if (emailTask.IsCanceled)
            {
                debugText.text = "ResendVerificationEmail emailTask.IsCanceled";
            }
            if (emailTask.IsFaulted)
            {
                debugText.text = "ResendVerificationEmail emailTask.IsFaulted";
            }
            if (emailTask.IsCompleted)
            {
                Debug.Log("ResendVerificationEmail email send to " + newUser.Email);
                debugText.text = "ResendVerificationEmail email send to " + newUser.Email;
            }
        });
    }
Пример #6
0
        ///<summary>
        ///Tries to create an account for the user in player accounts (now using firebase as of nov '19)
        ///</summary>
        public async static void TryCreateAccount(string proposedName, string _password, string emailAcc,
                                                  Action <CharacterSettings> callBack, Action <string> errorCallBack)
        {
            try
            {
                FirebaseUser user = await FirebaseAuth.DefaultInstance.CreateUserWithEmailAndPasswordAsync(emailAcc, _password);

                await user.SendEmailVerificationAsync();

                UserProfile profile = new UserProfile
                {
                    DisplayName = proposedName,
                    PhotoUrl    = null
                };

                await user.UpdateUserProfileAsync(profile);

                Logger.LogFormat($"Firebase user created successfully: {proposedName}",
                                 Category.DatabaseAPI);

                var newCharacter = new CharacterSettings
                {
                    Name     = StringManager.GetRandomMaleName(),
                    username = proposedName
                };

                callBack.Invoke(newCharacter);
            }
            catch (AggregateException ex)
            {
                var innerEx = ex.Flatten().InnerExceptions[0];
                Logger.LogError($"Failed to sign up {innerEx.Message}");
                errorCallBack.Invoke(innerEx.Message);
            }
            catch (Exception ex)
            {
                Logger.LogError($"Failed to sign up {ex.Message}");
                errorCallBack.Invoke(ex.Message);
            }
        }
Пример #7
0
    /// <summary>
    /// perform sending verification email to user's registerated email account
    /// </summary>
    /// <param name="callback">callback to notify user when task is finsihed</param>
    /// <exception cref="System.ArgumentNullException">Thrown when callback not provided</exception>
    public void sendVerificaitionEmail(Action <bool, string> callback)
    {
        if (callback == null)
        {
            throw new ArgumentNullException("callback is not provided");
        }

        FirebaseUser user = getFirebaseUser();

        user.SendEmailVerificationAsync().ContinueWithOnMainThread(task =>
        {
            string message = readError(task);
            if (message != null)
            {
                callback(false, message);
                return;
            }

            message = "Please verify you account from your email";
            callback(true, message);
        });
    }
    public async Task T_AuthSignIn_Task()
    {
        Assert.That(FirebaseToolkit <FT> .IsSignedIn, Is.Not.True, $"{nameof(FirebaseToolkit<FT>.IsSignedIn)} is false from the start.");

        FirebaseUser user = await Auth.SignInWithEmailAndPasswordAsync(TestAccountIdentifier, TestAccountPassword);

        Assert.That(FirebaseToolkit <FT> .IsSignedIn, Is.True, "Real sign in works in both editor and real device.");

        Assert.That(user.UserId, Is.EqualTo(TestAccountUID));
        Assert.That(user.Email, Is.EqualTo(TestAccountIdentifier));

        if (user.IsEmailVerified == false)
        {
            Debug.LogError($"Test account is still unverified. A verification e-mail has been sent to {TestAccountIdentifier}. Verify it and run the test again!");
            await user.SendEmailVerificationAsync();
        }

        Assert.That(user.IsEmailVerified, Is.True);
        Assert.That(user.IsAnonymous, Is.Not.True);

        Debug.Log("Signed in");
    }
    public static void AuthVerification()
    {
        if (User != null)
        {
            User.SendEmailVerificationAsync().ContinueWith(Task =>
            {
                if (Task.IsCanceled)
                {
                    Debug.LogError("Firebase Auth - SendEmailVerificationAsync foi cancelada.");
                    TecWolf.System.SystemInterface.Alert("A verificação de conta por Email foi cancelada.");
                    return;
                }
                if (Task.IsFaulted)
                {
                    Debug.LogError("Firebase Auth - SendEmailVerificationAsync encontrou um erro: " + Task.Exception);
                    TecWolf.System.SystemInterface.Alert("Erro ao enviar verificação de conta por Email.");
                    return;
                }

                Debug.Log("Firebase Auth - Email enviado com sucesso.");
                TecWolf.System.SystemInterface.Alert("Verificação de conta por Email enviada com sucesso.");
            });
        }
    }
 public Task SendEmailVerificationAsync(ActionCodeSettings actionCodeSettings = null)
 {
     return(_wrapped.SendEmailVerificationAsync(actionCodeSettings?.ToNative()));
 }