public void Start()
    {
        // Hide all our panels until we know what UI to display
        LoginPanel.SetActive(false);
        LoggedinPanel.SetActive(false);
        RegisterPanel.SetActive(false);
        SigninPanel.SetActive(true);

        // Subscribe to events that happen after we authenticate
        PlayFabAuthService.OnDisplayAuthentication += OnDisplayAuthentication;
        PlayFabAuthService.OnLoginSuccess          += OnLoginSuccess;
        PlayFabAuthService.OnPlayFabError          += OnPlayFaberror;

        // Bind to UI buttons to perform actions when user interacts with the UI.
        LoginButton.onClick.AddListener(OnLoginClicked);
        PlayAsGuestButton.onClick.AddListener(OnPlayAsGuestClicked);
        RegisterButton.onClick.AddListener(OnRegisterButtonClicked);
        CancelRegisterButton.onClick.AddListener(OnCancelRegisterButtonClicked);
        ResetSampleButton.onClick.AddListener(OnResetSampleButtonClicked);
        ClearSigninButton.onClick.AddListener(OnClearSigninButtonClicked);

        // Set the data we want at login from what we chose in our meta data.
        _AuthService.InfoRequestParams = InfoRequestParams;

        // Start the authentication process.
        _AuthService.Authenticate();
    }
 void Awake()
 {
     if (!string.IsNullOrEmpty(TitleIdOverride))
     {
         PlayFabSettings.TitleId = TitleIdOverride;
     }
     PlayFabAuthService.OnDisplayAuthentication += OnPlayFabDisplayAuth;
     PlayFabAuthService.OnLoginSuccess          += OnPlayFabLoggedIn;
     _service.InfoRequestParams = new GetPlayerCombinedInfoRequestParams()
     {
         GetPlayerProfile   = true,
         GetUserAccountInfo = true,
         GetTitleData       = true
     };
     _service.Authenticate();
 }
Exemple #3
0
    public void EmailPasswordLoginSuccess(UUnitTestContext testContext)
    {
        const string email    = "*****@*****.**";
        const string password = "******";
        const string username = "******";

        _emailAuthService          = new PlayFabAuthService();
        _emailAuthService.Email    = email;
        _emailAuthService.Password = password;
        _emailAuthService.Username = username;

        _emailAuthService.OnLoginSuccess += (success) =>
        {
            testContext.True(!string.IsNullOrEmpty(success.PlayFabId));
            testContext.NotNull(_emailAuthService.IsClientLoggedIn());
            testContext.EndTest(UUnitFinishState.PASSED, "Email & password auth success. " + success.PlayFabId);
        };
        _emailAuthService.OnPlayFabError += (error) =>
        {
            testContext.Fail("Email & password auth failed with error: " + error.GenerateErrorReport());
        };
        _emailAuthService.OnDisplayAuthentication += () =>
        {
            testContext.Fail("Email & password auth failed.");
        };
        _emailAuthService.Authenticate(AuthTypes.EmailPassword);
    }
Exemple #4
0
    public void InvalidServiceSetup(UUnitTestContext testContext)
    {
        var authService = new PlayFabAuthService();

        authService.OnDisplayAuthentication += () => testContext.EndTest(UUnitFinishState.PASSED, "Invoke display as expected.");
        authService.OnLoginSuccess          += (success) => testContext.Fail("Invoke display expected.");
        authService.OnPlayFabError          += (error) => testContext.EndTest(UUnitFinishState.PASSED, "Error is not expected.");
        authService.Authenticate(AuthTypes.UsernamePassword);
    }
    void Start()
    {
        mainPanel.SetActive(true);
        registerPanel.SetActive(false);

        // subscribe to events that happen after we authenticate
        // we are telling the delegate in PlayFabAuthService to call this method
        PlayFabAuthService.OnDisplayAuthentication += OnDisplayAuthentication;
        PlayFabAuthService.OnLoginSuccess          += OnLoginSuccess;
        PlayFabAuthService.OnPlayFabError          += OnPlayFaberror;

        loginButton.onClick.AddListener(OnLoginClicked);
        loginWithGoogle.onClick.AddListener(OnLoginWithGoogleClicked);
        registerButton.onClick.AddListener(OnRegisterButtonClicked);
        cancelRegisterButton.onClick.AddListener(OnCancelRegisterButtonClicked);

        _AuthService.InfoRequestParams = InfoRequestParams;

        _AuthService.Authenticate();
    }
Exemple #6
0
    public void TestSilentLoginAfterUnlink(UUnitTestContext testContext)
    {
        var silentAuth = new PlayFabAuthService();

        silentAuth.OnLoginSuccess += (success) =>
        {
            testContext.True(success.PlayFabId != _emailAuthService.AuthenticationContext.PlayFabId, "Silent auth and email auth playFabIds is match!");
            testContext.EndTest(UUnitFinishState.PASSED, "Silent auth completed as expected. New playFabId: " + success.PlayFabId);
        };
        silentAuth.OnPlayFabError += (error) =>
        {
            testContext.Fail("Silent auth abort with error: " + error.Error.ToString());
        };
        silentAuth.Authenticate(AuthTypes.Silent);
    }
Exemple #7
0
    public void LoginWithDeviceId(UUnitTestContext testContext)
    {
        var silentAuth = new PlayFabAuthService();

        silentAuth.OnLoginSuccess += (success) =>
        {
            testContext.StringEquals(_emailAuthService.AuthenticationContext.PlayFabId, success.PlayFabId);
            testContext.EndTest(UUnitFinishState.PASSED, "Silent auth success with playFabId: " + success.PlayFabId);
        };
        silentAuth.OnPlayFabError += (error) =>
        {
            testContext.Fail("Silent auth failed with error: " + error.ErrorMessage);
        };
        silentAuth.Authenticate(AuthTypes.Silent);
    }
Exemple #8
0
    public void InvalidEmailPasswordLogin(UUnitTestContext testContext)
    {
        const string password = "******";
        const string username = "******";
        const string email    = "LoginTest.com";

        var authService = new PlayFabAuthService();

        authService.Password = password;
        authService.Username = username;
        authService.Email    = email;

        authService.OnLoginSuccess          += (success) => testContext.Fail("Login fail expected.");
        authService.OnPlayFabError          += (error) => testContext.EndTest(UUnitFinishState.PASSED, "Error handle as expected.");
        authService.OnDisplayAuthentication += () => testContext.Fail("Failed with unknown error.");

        authService.Authenticate(AuthTypes.UsernamePassword);
    }
Exemple #9
0
 private void OnConnected()
 {
     _authService.Authenticate();
 }