예제 #1
0
 public void thirdPartySignIn(string way, AGConnectAuthCredential credential)
 {
     if (way == LOGIN)
     {
         AGConnectAuth.getInstance().signIn(credential)
         .addOnSuccessListener(new HuaweiOnsuccessListener <SignInResult>(C =>
         {
             PanelController.popupinstance.ShowInfo("Login success!");
             Debug.Log("Login success!");
             PanelController.userInfo.ParentPanel = this;
             PanelController.getInstance().OpenPanel(PanelController.userInfo);
         }))
         .addOnFailureListener(new HuaweiOnFailureListener((exception) =>
         {
             failedSteps(exception.toString());
         }));
     }
     else
     {
         AGConnectAuth.getInstance().getCurrentUser().link(credential)
         .addOnSuccessListener(new HuaweiOnsuccessListener <SignInResult>(C =>
         {
             PanelController.popupinstance.ShowInfo("Link success!");
             PanelController.userInfo.ParentPanel = this;
             PanelController.getInstance().OpenPanel(PanelController.userInfo);
         }))
         .addOnFailureListener(new HuaweiOnFailureListener((exception) =>
         {
             failedSteps(exception.toString());
         }));
     }
 }
예제 #2
0
 public void resetPassword()
 {
     try
     {
         AGConnectAuth.getInstance().resetPassword("+86", phoneNumber.text.Trim(), password.text.Trim(), smsCode.text.Trim())
         .addOnSuccessListener(new HuaweiOnsuccessListener <Void>((temp) =>
         {
             UnityMainThread.instance.AddJob(() =>
             {
                 PanelController.popupinstance.ShowInfo("reset successfully!");
                 infoMessage.text = "reset successfully!";
             });
         })).addOnFailureListener(new HuaweiOnFailureListener((e
                                                               ) =>
         {
             UnityMainThread.instance.AddJob(() =>
             {
                 Error error   = new Error();
                 error.message = e.toString();
                 PanelController.popupinstance.ShowError(error);
                 infoMessage.text = e.toString();
             });
         }));
     }
     catch (System.Exception e)
     {
         Error error = new Error();
         error.message = e.Message;
         PanelController.popupinstance.ShowError(error);
     }
 }
예제 #3
0
        public void OnSignUpClicked()
        {
            EmailUser emailUser = new EmailUser.Builder()
                                  .setEmail(emailorPhone.text)
                                  .setVerifyCode(verifyCode.text)
                                  .setPassword(password.text)
                                  .build();

            AGConnectAuth.getInstance().createUser(emailUser)
            .addOnSuccessListener(new HuaweiOnsuccessListener <SignInResult>((signresult) =>
            {
                UnityMainThread.instance.AddJob(() =>
                {
                    PanelController.popupinstance.ShowInfo("sign up successfully!");
                    PanelController.userInfo.ParentPanel = this;
                    PanelController.getInstance().OpenPanel(PanelController.userInfo);
                });
            })).addOnFailureListener(new HuaweiOnFailureListener((e
                                                                  ) =>
            {
                UnityMainThread.instance.AddJob(() =>
                {
                    Error error   = new Error();
                    error.message = "Login failed" + e.ToString();
                    PanelController.popupinstance.ShowError(error);
                });
            }));
        }
        public void OnUnLinkClick(int provider)
        {
            if (AGConnectAuth.getInstance().getCurrentUser() != null)
            {
                AGConnectAuth.getInstance().getCurrentUser().unlink(provider);
            }

            PanelController.popupinstance.ShowInfo("unlink success!");
        }
예제 #5
0
 public void OnModifyClick()
 {
     instance      = AGConnectAuth.getInstance();
     agConnectUser = instance.getCurrentUser();
     if (agConnectUser != null)
     {
         try
         {
             if (!isModifyPassword)
             {
                 if (isPhoneOrEmail)
                 {
                     modifyTask = agConnectUser
                                  .updateEmail(newemailorPhoneorpassword.text.Trim(), verifyCode.text.Trim());
                 }
                 else
                 {
                     modifyTask = agConnectUser
                                  .updatePhone("+86", newemailorPhoneorpassword.text.Trim(), verifyCode.text.Trim());
                 }
             }
             else
             {
                 modifyTask = agConnectUser.updatePassword(
                     newemailorPhoneorpassword.text.Trim(),
                     verifyCode.text.Trim(),
                     isPhoneOrEmail
                         ? AGConnectAuthCredential.Email_Provider
                         : AGConnectAuthCredential.Phone_Provider);
             }
             modifyTask.addOnSuccessListener(new HuaweiOnsuccessListener <SignInResult>((signresult) =>
             {
                 PanelController.popupinstance.ShowInfo("modify successfully!");
                 showMessage.text = "modify successfully!";
                 PanelController.getInstance().OpenPanel(PanelController.userInfo);
             })).addOnFailureListener(new HuaweiOnFailureListener((e
                                                                   ) =>
             {
                 Error error   = new Error();
                 error.message = e.toString();
                 PanelController.popupinstance.ShowError(error);
                 showMessage.text = e.toString();
             }));
         }
         catch (System.Exception e)
         {
             Error error = new Error();
             error.message    = e.Message;
             showMessage.text = e.Message;
             PanelController.popupinstance.ShowError(error);
         }
     }
     else
     {
         showMessage.text = "User is null!";
     }
 }
        public void login()
        {
            AGConnectAuth auth = AGConnectAuth.getInstance();

            auth.signInAnonymously().addOnSuccessListener(new HuaweiOnsuccessListener <SignInResult> ((signresult) => {
                TestTip.Inst.ShowText("sign in successfully." + signresult.getUser().getUid());
            })).addOnFailureListener(new HuaweiOnFailureListener((e) => {
                TestTip.Inst.ShowText("sign in failed");
            }));
        }
예제 #7
0
        public bool haveCurrentUser(AbstractPanel parentPanel)
        {
            AGConnectUser user = AGConnectAuth.getInstance().getCurrentUser();

            if (user == null)
            {
                return(false);
            }
            ParentPanel = parentPanel;
            PanelController.getInstance()
            .OpenPanel(PanelController.getInstance().GetComponentInChildren <UserAccount>());
            return(true);
        }
예제 #8
0
        public override void OpenPanel()
        {
            base.OpenPanel();
            clearTextValue();
            try
            {
                agConnectUser = AGConnectAuth.getInstance().getCurrentUser();
                if (agConnectUser != null)
                {
                    UserNikeName.text     = agConnectUser.getDisplayName();
                    UserEmail.text        = agConnectUser.getEmail();
                    UserPhoneNumber.text  = agConnectUser.getPhone();
                    photoUrl.text         = agConnectUser.getPhotoUrl();
                    UserId.text           = agConnectUser.getUid();
                    UserProviderId.text   = agConnectUser.getProviderId();
                    UserProviderInfo.text = transferProviderInfo(agConnectUser.getProviderInfo());
                    agConnectUser.getToken(false).addOnSuccessListener(new HuaweiOnsuccessListener <TokenResult>(
                                                                           (result) =>
                    {
                        UnityMainThread.instance.AddJob(() =>
                        {
                            UserToken.text = result.getToken() + "  " + result.getExpirePeriod();
                        });
                    }
                                                                           ));

                    agConnectUser.getUserExtra().addOnSuccessListener(new HuaweiOnsuccessListener <AGConnectUserExtra>(
                                                                          (UserExtraInfo) =>
                    {
                        UnityMainThread.instance.AddJob(() =>
                        {
                            UserExtra.text = UserExtraInfo.getCreateTime() + "  " +
                                             UserExtraInfo.getLastSignInTime();
                        });
                    }));
                    isAnonymous.text = agConnectUser.isAnonymous()
                        ? "true"
                        : "false" + "  " + agConnectUser.getEmailVerified() + "   " + agConnectUser.getPasswordSetted();
                }
            }
            catch (System.Exception e)
            {
                Error error = new Error();
                error.message = e.Message;
                Debug.Log("this error is " + error.message);
                PanelController.popupinstance.ShowError(error);
            }
        }
예제 #9
0
 public void AnonymousLoginClick()
 {
     AGConnectAuth.getInstance().signInAnonymously()
     .addOnSuccessListener(new HuaweiOnsuccessListener <SignInResult>((signresult) =>
     {
         PanelController.popupinstance.ShowInfo("Login in successfully");
         PanelController.userInfo.ParentPanel = this;
         PanelController.getInstance().OpenPanel(PanelController.userInfo);
     })).addOnFailureListener(new HuaweiOnFailureListener((e
                                                           ) =>
     {
         Error error   = new Error();
         error.message = e.toString();
         PanelController.popupinstance.ShowError(error);
     }));
 }
예제 #10
0
        public void OnLoginClicked()
        {
            try
            {
                if (smsCode.text.Trim() == "")
                {
                    credential =
                        PhoneAuthProvider.credentialWithPassword("+86", phoneNumber.text.Trim(), password.text.Trim());
                }
                else
                {
                    credential =
                        PhoneAuthProvider.credentialWithVerifyCode("+86", phoneNumber.text.Trim(), password.text.Trim(),
                                                                   smsCode.text.Trim());
                }

                AGConnectAuth.getInstance().signIn(credential)
                .addOnSuccessListener(new HuaweiOnsuccessListener <SignInResult>((signresult) =>
                {
                    UnityMainThread.instance.AddJob(() =>
                    {
                        PanelController.popupinstance.ShowInfo("Login success!");
                        PanelController.userInfo.ParentPanel = this;
                        infoMessage.text = "login success!";
                        PanelController.getInstance().OpenPanel(PanelController.userInfo);
                    });
                })).addOnFailureListener(new HuaweiOnFailureListener((e
                                                                      ) =>
                {
                    UnityMainThread.instance.AddJob(() =>
                    {
                        Error error   = new Error();
                        error.message = e.toString();
                        PanelController.popupinstance.ShowError(error);
                        infoMessage.text = e.toString();
                    });
                }));
            }
            catch (System.Exception e)
            {
                Error error = new Error();
                error.message = e.Message;
                PanelController.popupinstance.ShowError(error);
            }
        }
예제 #11
0
        public void OnLoginClicked()
        {
            try
            {
                if (verifyCode.text.Trim() != "")
                {
                    credential =
                        EmailAuthProvider.credentialWithVerifyCode(email.text.Trim(), password.text.Trim(), verifyCode.text.Trim());
                }
                else
                {
                    credential =
                        EmailAuthProvider.credentialWithPassword(email.text, password.text);
                }

                if (credential.getProvider() == AGConnectAuthCredential.Email_Provider)
                {
                    AGConnectAuth.getInstance().signIn(credential)
                    .addOnSuccessListener(new HuaweiOnsuccessListener <SignInResult>((signresult) =>
                    {
                        UnityMainThread.instance.AddJob(() =>
                        {
                            PanelController.popupinstance.ShowInfo("Login in successfully");
                            PanelController.userInfo.ParentPanel = this;
                            PanelController.getInstance().OpenPanel(PanelController.userInfo);
                        });
                    })).addOnFailureListener(new HuaweiOnFailureListener((e
                                                                          ) =>
                    {
                        UnityMainThread.instance.AddJob(() =>
                        {
                            Error error   = new Error();
                            error.message = e.toString();
                            PanelController.popupinstance.ShowError(error);
                        });
                    }));
                }
            }
            catch (System.Exception e)
            {
                Error error = new Error();
                error.message = e.Message;
                PanelController.popupinstance.ShowError(error);
            }
        }
        public void OnSignUpButtonClick()
        {
            if (password.text != passwordConfirmation.text)
            {
                Error error = new Error();
                error.message = "两次输入的密码不一致";
                PanelController.popupinstance.ShowError(error);
                return;
            }

            try
            {
                PhoneUser phoneUser = new PhoneUser.Builder()
                                      .setCountryCode(regionText)
                                      .setPhoneNumber(emailorPhone.text)
                                      .setVerifyCode(verifyCode.text)
                                      .setPassword(password.text)
                                      .build();
                AGConnectAuth.getInstance().createUser(phoneUser)
                .addOnSuccessListener(new HuaweiOnsuccessListener <SignInResult>((signresult) =>
                {
                    UnityMainThread.instance.AddJob(() =>
                    {
                        PanelController.popupinstance.ShowInfo("sign up successfully!");
                        PanelController.userInfo.ParentPanel = this;
                        PanelController.getInstance().OpenPanel(PanelController.userInfo);
                    });
                })).addOnFailureListener(new HuaweiOnFailureListener((e
                                                                      ) =>
                {
                    UnityMainThread.instance.AddJob(() =>
                    {
                        Error error   = new Error();
                        error.message = e.toString();
                        PanelController.popupinstance.ShowError(error);
                    });
                }));
            }catch (System.Exception e) {
                Error error = new Error();
                error.message = e.Message;
                PanelController.popupinstance.ShowError(error);
            }
        }
예제 #13
0
        public void LogOutClick()
        {
            try
            {
                if (AGConnectAuth.getInstance() != null)
                {
                    AGConnectAuth.getInstance().signOut();
                    PanelController.popupinstance.ShowInfo("User has been sign out!");
                    PanelController.getInstance().OpenPanel(PanelController.getInstance().GetComponentInChildren <SignInPanel>());
                }
            } catch (System.Exception e)
            {
                Error error = new Error();
                error.message = e.Message;
                PanelController.popupinstance.ShowError(error);
            }

            PanelController.getInstance().OpenPanel(PanelController.getInstance().GetComponentInChildren <SignInPanel>());
        }
예제 #14
0
 public void LogOutClick()
 {
     try
     {
         if (AGConnectAuth.getInstance().getCurrentUser() != null)
         {
             AGConnectAuth.getInstance().signOut();
             PanelController.popupinstance.ShowInfo("User has been sign out!");
         }
         else
         {
             PanelController.popupinstance.ShowInfo("Don't need log out, no user");
         }
     } catch (System.Exception e)
     {
         Error error = new Error();
         error.message = e.Message;
         PanelController.popupinstance.ShowError(error);
     }
 }
예제 #15
0
 public void ResetpasswordClick()
 {
     try{
         AGConnectAuth.getInstance().resetPassword(email.text.Trim(), password.text.Trim(), verifyCode.text.Trim()).addOnSuccessListener(new HuaweiOnsuccessListener <AndroidJavaObject>((temp) =>
         {
             PanelController.popupinstance.ShowInfo("reset successfully!");
         })).addOnFailureListener(new HuaweiOnFailureListener((e
                                                               ) =>
         {
             Error error   = new Error();
             error.message = e.toString();
             PanelController.popupinstance.ShowError(error);
         }));
     }
     catch (System.Exception e)
     {
         Error error = new Error();
         error.message = e.Message;
         PanelController.popupinstance.ShowError(error);
     }
 }
예제 #16
0
        void Start()
        {
            UserNikeName.text    = "";
            UserEmail.text       = "";
            UserPhoneNumber.text = "";
            LogOut.onClick.AddListener(() => LogOutClick());
            modifyEmail.onClick.AddListener(() =>
            {
                if (UserEmail.text == "" || UserEmail.text == "Null")
                {
                    PanelController.popupinstance.ShowInfo("the email is Null, you can't modify it");
                    MessageInfo.text = "the email is Null, you can't modify it";
                    return;
                }

                OnModifyClick(true, false);
            });
            modifyPhone.onClick.AddListener(() =>
            {
                if (UserPhoneNumber.text == "" || UserPhoneNumber.text == "Null")
                {
                    PanelController.popupinstance.ShowInfo("the phone is Null, you can't modify it");
                    MessageInfo.text = "the phone is Null, you can't modify it";

                    return;
                }

                OnModifyClick(false, false);
            });
            modifyEmailPassword.onClick.AddListener(() =>
            {
                if (UserEmail.text == "" || UserEmail.text == "Null")
                {
                    PanelController.popupinstance.ShowInfo("the email is Null, you can't modify it");
                    MessageInfo.text = "the email is Null, you can't modify it";
                    return;
                }

                OnModifyClick(true, true);
            });
            modifyPhonePassword.onClick.AddListener(() =>
            {
                if (UserPhoneNumber.text == "" || UserPhoneNumber.text == "Null")
                {
                    PanelController.popupinstance.ShowInfo("the phone is Null, you can't modify it");
                    MessageInfo.text = "the phone is Null, you can't modify it";
                    return;
                }

                OnModifyClick(false, true);
            });
            deleteUser.onClick.AddListener(() =>
            {
                AGConnectAuth.getInstance().deleteUser();
                PanelController.popupinstance.ShowInfo("the user has been delete!");
                PanelController.getInstance()
                .OpenPanel(PanelController.getInstance().GetComponentInChildren <SignInPanel>());
            });

            Link.onClick.AddListener(() =>
            {
                PanelController.getInstance().GetComponentInChildren <LinkThirdParty>().ParentPanel = this;
                PanelController.getInstance()
                .OpenPanel(PanelController.getInstance().GetComponentInChildren <LinkThirdParty>());
            });
        }