Ejemplo n.º 1
0
 //----------------------------------------ACCOUNT (We send OnFailed too to keep the possibility to identify an error on the user-side. We could upgrade this part)
 public void StartLogin()
 {
     if (!PlayerPrefs.HasKey(KEY_ID) || !PlayerPrefs.HasKey(KEY_PWD) || !ProfileHolder.IsEmail(PlayerPrefs.GetString(KEY_ID)) || !IsRegisteredEmail)
     {
         LoginAnonymously();
     }
     else
     {
         SignIn(PlayerPrefs.GetString(KEY_ID), PlayerPrefs.GetString(KEY_PWD));
     }
 }
Ejemplo n.º 2
0
    private void OnRecover()
    {
        if (!ProfileHolder.IsEmail(emailInput.text))
        {
            HintItIsNotEmail();
            Debug.LogWarning("Need a real email to recover");
            return;
        }

        HintCantRecoveredPassword(); //TO DELETE IF WE USE A REAL API KEY (registered with no 2FA and with a debit card)
        CloudManager.Instance.Profile.ResetPassword(emailInput.text, OnRecovered, OnFailedRecovered);
    }
Ejemplo n.º 3
0
    //SignIn Results (For security, I think it's useless to have a splitted behaviour to know if this email is registered. But I would like to show that it's possible to)
    private void OnSuccessSignIn(string _id, string _pwd)
    {
        if (ProfileHolder.IsEmail(_id))
        {
            PlayerPrefs.SetInt(ProfileHolder.KEY_NETWORK, 1);
        }
        else
        {
            PlayerPrefs.SetInt(ProfileHolder.KEY_NETWORK, 0);
        }

        PlayerPrefs.SetString(ProfileHolder.KEY_ID, _id);
        PlayerPrefs.SetString(ProfileHolder.KEY_PWD, _pwd);
        PlayerPrefs.Save();

        cachedMail = _id;
        cachedPass = _pwd;

        ChangeState(WindowState.Connected);
        CloseWindow();
    }
Ejemplo n.º 4
0
    private void OnValidation()
    {
        if (!ProfileHolder.IsEmail(emailInput.text))
        {
            HintItIsNotEmail();
            ShakeCourriel();
            return;
        }

        switch (currentState)
        {
        case WindowState.SignIn:

            if (passwordInput.text != "" && ProfileHolder.IsPassword(passwordInput.text))
            {
                CloudManager.Instance.Profile.SignIn(emailInput.text, passwordInput.text, OnSuccessSignIn, FailedSignIn);
            }
            else
            {
                CloudManager.Instance.Profile.SignIn(emailInput.text, PlayerPrefs.GetString(ProfileHolder.KEY_PWD), OnSuccessSignIn, FailedSignIn);
            }

            //Automatic accound creation (I don't want this but it's possible like this)
            //CloudManager.Instance.Profile.LoginWithEmail(emailInput.text, passwordInput.text, OnFinishedMailAndPasswordEditing, OnFailedSignIn);
            break;

        case WindowState.SignUp:
            if (passwordInput.text != cachedPass)    //Has changed his password
            {
                if (ProfileHolder.IsPassword(passwordInput.text))
                {
                    CloudManager.Instance.Profile.SignUp(emailInput.text, passwordInput.text, OnFinishedMailAndPasswordEditing, OnNoRegisteredEmail);
                }
                else
                {
                    HintItIsNotAPassword();
                    ShakePadlock();
                }
            }
            else     //Has not changed his password in forms
            {
                if (ProfileHolder.IsPassword(PlayerPrefs.GetString(ProfileHolder.KEY_PWD)))
                {
                    CloudManager.Instance.Profile.SignUp(emailInput.text, PlayerPrefs.GetString(ProfileHolder.KEY_PWD), OnFinishedMailAndPasswordEditing, OnAlreadyRegisteredEmail);
                }
                else
                {
                    ShakePadlock();
                    Debug.LogError("The user has changed is password not properly ??");
                }
            }
            break;

        default:     //Connected
            if (emailInput.text != cachedMail)
            {
                CloudManager.Instance.Profile.ChangeEmail(emailInput.text, OnFinishedMailEditingAndChangeState);
            }

            if (passwordInput.text != PlayerPrefs.GetString(ProfileHolder.KEY_PWD) && ProfileHolder.IsPassword(passwordInput.text))
            {
                CloudManager.Instance.Profile.ChangePassword(passwordInput.text, OnFinishedPasswordEditingAndChangeState);
            }
            break;
        }
    }