예제 #1
0
    /// <summary>
    /// Signs up.
    /// </summary>
    /// <returns>A Unity coroutine IEnumerator.</returns>
    private IEnumerator SignUp()
    {
        // Add custom values if any
        demoUser.SetValue(firstNameColumn, signUpFirstNameField.text);
        demoUser.SetValue(lastNameColumn, signUpLastNameField.text);
        demoUser.SetValue(ageColumn, signUpAgeField.text);

        // Create signup request.
        MoBackRequest signUpNewUserRequest = demoUser.SignUp();

        // Send SignUp request.
        yield return(signUpNewUserRequest.Run());

        // If request can't complete, exit.
        if (signUpNewUserRequest.State != MoBackRequest.RequestState.COMPLETED)
        {
            Debug.LogError("Error: Account creation unsuccessful.");
            Display("Account creation unsuccessful");
            yield break;
        }
        else
        {
            ChangeScene(signedInPrompt);
            Display("User account creation successful");
        }

        // If signup request is complete, but we can't sign up. Mostly because there is already an existence account.
        // We give a error message here.
        if (!demoUser.CompleteSignedUp)
        {
            Debug.LogError("Error: User already exists. New column won't be stored on the server.");
            Display("User already exists - New column won't be stored on the server");
        }
    }
예제 #2
0
    /// <summary>
    /// Logins the user.
    /// </summary>
    /// <returns>The user.</returns>
    /// <param name="name">Name.</param>
    /// <param name="password">Password.</param>
    public IEnumerator LoginUser()
    {
        // Disable all buttons while signing up and logging in.
        uploadFileButton.enabled   = false;
        downloadFileButton.enabled = false;
        deleteFileButton.enabled   = false;

        // Create a new user.
        demoUser = new MoBackUser(demoMobackUser, demoMoBackPassword, demoMoBackEmail);

        // Sign up for the demo user.
        MoBackRequest signUpRequest = demoUser.SignUp();

        yield return(signUpRequest.Run());

        MoBackRequest currentLoginRequest = demoUser.Login();

        yield return(currentLoginRequest.Run());

        if (currentLoginRequest.State == MoBackRequest.RequestState.COMPLETED)
        {
            if (demoUser.IsLoggedIn)
            {
                // enable all button when logging complete.
                uploadFileButton.enabled   = true;
                downloadFileButton.enabled = true;
                deleteFileButton.enabled   = true;
                Debug.Log("Login Complete");
            }
            else
            {
                Debug.Log("Can't log in");
            }

            DisplayMessage(currentLoginRequest.message);
        }
        else if (currentLoginRequest.State == MoBackRequest.RequestState.ERROR)
        {
            DisplayMessage(currentLoginRequest.errorDetails.Message);
        }
    }