示例#1
0
        private void EmailLogin()
        {
            AGCAuthCredential credential;
            string            email            = accountText.Text;
            string            password         = passwordText.Text;
            string            verificationCode = codeText.Text;

            if (codeText.Text.Length == 0)
            {
                // Generate a credential to sign in to email account with password
                credential = AGCEmailAuthProvider.CredentialWithEmail(email, password);
            }
            else
            {
                // Generate a credential to sign in to email account with verification code
                credential = AGCEmailAuthProvider.CredentialWithEmail(email, password, verificationCode);
            }
            SignInWithCredential(credential);
        }
示例#2
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");
                    });
                });
            });
        }