private void OnAuthSericeCreateUserSuccess(SignInResult signInResult)
 {
     user = signInResult.GetUser();
     loggedInUser.text = user.IsAnonymous() ? LOGGED_IN_ANONYMOUSLY : string.Format(LOGGED_IN, user.DisplayName);
     verifyCodePhone.SetActive(false);
     verifyCodeEmail.SetActive(false);
 }
    public void Start()
    {
        loggedInUser      = GameObject.Find("LoggedUserText").GetComponent <Text>();
        loggedInUser.text = NOT_LOGGED_IN;

        authServiceManager = new AuthServiceManager();
        authServiceManager.GetInstance();
        authServiceManager.OnSignInSuccess = OnAuthSericeSignInSuccess;
        authServiceManager.OnSignInFailed  = OnAuthSericeSignInFailed;

        if (authServiceManager.GetCurrentUser() != null)
        {
            user = authServiceManager.GetCurrentUser();
            loggedInUser.text = user.IsAnonymous() ? LOGGED_IN_ANONYMOUSLY : string.Format(LOGGED_IN, user.DisplayName);
        }
        else
        {
            SignInWithHuaweiAccount();
        }

        cloudDBManager = new CloudDBManager();
        cloudDBManager.Initialize();
        cloudDBManager.GetInstance();
        cloudDBManager.OnExecuteQuerySuccess = OnExecuteQuerySuccess;
        cloudDBManager.OnExecuteQueryFailed  = OnExecuteQueryFailed;
    }
    public void Start()
    {
        loggedInUser      = GameObject.Find("LoggedUserText").GetComponent <Text>();
        loggedInUser.text = NOT_LOGGED_IN;

        PhoneCountryCode = GameObject.Find("PhoneCountryCode").GetComponent <InputField>();
        PhoneNumber      = GameObject.Find("PhoneNumber").GetComponent <InputField>();
        EmailAddress     = GameObject.Find("EmailAddress").GetComponent <InputField>();

        PhoneVerifyCode = verifyCodePhone.transform.Find("PhoneVerifyCode").GetComponent <InputField>();
        PhonePassword   = verifyCodePhone.transform.Find("PhonePassword").GetComponent <InputField>();

        EmailVerifyCode = verifyCodeEmail.transform.Find("EmailVerifyCode").GetComponent <InputField>();
        EmailPassword   = verifyCodeEmail.transform.Find("EmailPassword").GetComponent <InputField>();

        authServiceManager = new AuthServiceManager();
        authServiceManager.GetInstance();
        authServiceManager.OnSignInSuccess     = OnAuthSericeSignInSuccess;
        authServiceManager.OnSignInFailed      = OnAuthSericeSignInFailed;
        authServiceManager.OnCreateUserSuccess = OnAuthSericeCreateUserSuccess;
        authServiceManager.OnCreateUserFailed  = OnAuthSericeCreateUserFailed;

        if (authServiceManager.GetCurrentUser() != null)
        {
            user = authServiceManager.GetCurrentUser();
            loggedInUser.text = user.IsAnonymous() ? LOGGED_IN_ANONYMOUSLY : string.Format(LOGGED_IN, user.DisplayName);
        }
    }
 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!";
     }
 }
Esempio n. 5
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);
        }
Esempio n. 6
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);
            }
        }
Esempio n. 7
0
        private void ShowUserInfo()
        {
            AGConnectUser agConnectUser = AGConnectAuth.Instance.CurrentUser;
            string        uid           = agConnectUser.Uid;
            string        nickName      = agConnectUser.DisplayName;
            string        email         = agConnectUser.Email;
            string        phone         = agConnectUser.Phone;
            string        photoUrl      = agConnectUser.PhotoUrl;

            tvUid.Text      = uid;
            tvNickName.Text = nickName;
            tvEmail.Text    = email;
            tvPhone.Text    = phone;
            if (!TextUtils.IsEmpty(photoUrl))
            {
                Picasso.Get().Load(photoUrl).Into(imgPhoto);
            }
        }
Esempio n. 8
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.activity_login);
            try
            {
                agConnectUser = AGConnectAuth.Instance.CurrentUser;
            }
            catch (Exception ex)
            {
                Log.Error(TAG, ex.Message);
            }

            if (agConnectUser != null)
            {
                StartActivity(new Intent(this, typeof(MainActivity)));
                Finish();
            }
            InitView();
        }
 private void OnAuthSericeSignInSuccess(SignInResult signInResult)
 {
     user = signInResult.GetUser();
     loggedInUser.text = user.IsAnonymous() ? LOGGED_IN_ANONYMOUSLY : string.Format(LOGGED_IN, user.DisplayName);
 }