private void UpdateEmailPassword()
        {
            CreateAlert("Send Verification Code", "", new[] { "Email" }, (resultArr) =>
            {
                var email = resultArr[0];
                BaseProvider.SendVerifyCodeWithEmail(email, AGCVerifyCodeAction.SetPassword);

                CreateAlert("Update Email Password", "", new[] { "Password", "Verification Code" }, (updateArr) =>
                {
                    var password = updateArr[0];
                    var code     = updateArr[1];

                    // update the password of the current user
                    HMFTask <NSObject> passwordReq = AGCAuth.GetInstance().CurrentUser?.UpdatePassword(password, code, (int)AGCAuthProviderType.Email);

                    passwordReq.AddOnSuccessCallback((result) =>
                    {
                        Console.WriteLine("password update success");
                    });
                    passwordReq.AddOnFailureCallback((error) =>
                    {
                        Console.WriteLine("password update failed");
                    });
                });
            });
        }
 private void UpdateEmail()
 {
     CreateAlert("Send Verification Code", "", new[] { "Email" }, (resultArr) =>
     {
         var email = resultArr[0];
         BaseProvider.SendVerifyCodeWithEmail(email, AGCVerifyCodeAction.RegisterLogin);
         CreateAlert("Update Email", "", new[] { "Email", "Verification Code" }, (updateArr) =>
         {
             var updatedEmail            = updateArr[0];
             var code                    = updateArr[1];
             HMFTask <NSObject> emailReq = AGCAuth.GetInstance().CurrentUser?.UpdateEmail(updatedEmail, code);
             emailReq.AddOnSuccessCallback((result) =>
             {
                 Console.WriteLine("email update success");
             });
             emailReq.AddOnFailureCallback((error) =>
             {
                 Console.WriteLine("email update failed");
             });
         });
     });
 }
Exemple #3
0
        private void LinkEmailAccount()
        {
            CreateAlert("Send Verification Code", "", new[] { "Email" }, (resultArr) =>
            {
                var email = resultArr[0];
                BaseProvider.SendVerifyCodeWithEmail(email, AGCVerifyCodeAction.RegisterLogin);

                CreateAlert("Link Email Account", "", new[] { "Email", "Password", "Verification Code" }, (linkArr) =>
                {
                    email        = linkArr[0];
                    var password = linkArr[1];
                    var code     = linkArr[2];
                    AGCAuthCredential credential;
                    if (string.IsNullOrEmpty(code))
                    {
                        // Generate a credential to link to email account with password
                        credential = AGCEmailAuthProvider.CredentialWithEmail(email, password: password);
                    }
                    else
                    {
                        // Generate a credential to link to email account with verification code
                        credential = AGCEmailAuthProvider.CredentialWithEmail(email, password: password, code);
                    }

                    var linkReq = AGCAuth.GetInstance().CurrentUser?.Link(credential);

                    linkReq.AddOnSuccessCallback((result) =>
                    {
                        Console.WriteLine("link success");
                        owner.RefreshLinkState();
                    });
                    linkReq.AddOnFailureCallback((error) =>
                    {
                        Console.WriteLine("link failed");
                    });
                });
            });
        }