示例#1
0
        private static HttpWebRequest GetAuthenticationRequest(
            IAuthenticationContext authenticationContext, string oauthToken)
        {
            RequestParameters authenticateRequestParameters =
                new AuthenticateRequestParameters(authenticationContext, oauthToken);

            return(GetWebRequest(authenticationContext, authenticateRequestParameters));
        }
示例#2
0
        private async Task Authenticate(IYield yield, AuthenticateRequestParameters parameters)
        {
            var loginPeerLogic     = ServiceContainer.LoginService.GetPeerLogic <ILoginPeerLogicAPI>().AssertNotNull();
            var responseParameters = await loginPeerLogic.Authenticate(yield, parameters);

            switch (responseParameters.Status)
            {
            case LoginStatus.Succeed:
            {
                var noticeWindow = UserInterfaceContainer.Instance.Get <NoticeWindow>().AssertNotNull();
                noticeWindow.Message.text = "You have logged in successfully!";
                break;
            }

            case LoginStatus.UserNotExist:
            {
                var noticeWindow = UserInterfaceContainer.Instance.Get <NoticeWindow>().AssertNotNull();
                noticeWindow.Message.text          = "The user does not exist. Please check your typed email.";
                noticeWindow.OkButton.interactable = true;
                break;
            }

            case LoginStatus.PasswordIncorrect:
            {
                var noticeWindow = UserInterfaceContainer.Instance.Get <NoticeWindow>().AssertNotNull();
                noticeWindow.Message.text          = "The password is incorrect, please type it again.";
                noticeWindow.OkButton.interactable = true;
                break;
            }

            case LoginStatus.NonAuthorized:
            {
                var noticeWindow = UserInterfaceContainer.Instance.Get <NoticeWindow>().AssertNotNull();
                noticeWindow.Message.text          = "Authentication with login server failed.";
                noticeWindow.OkButton.interactable = true;
                break;
            }

            default:
            {
                var noticeWindow = UserInterfaceContainer.Instance.Get <NoticeWindow>().AssertNotNull();
                noticeWindow.Message.text          = "Something went wrong, please try again.";
                noticeWindow.OkButton.interactable = true;
                break;
            }
            }

            if (responseParameters.Status == LoginStatus.Succeed)
            {
                OnLoginSucceed();
            }
        }
示例#3
0
        private void Login(string email, string password)
        {
            var noticeWindow = Utils.ShowNotice("Logging in... Please wait.", okButtonClicked: () =>
            {
                loginWindow.Show();
            });

            noticeWindow.OkButton.interactable = false;

            Action authenticateAction = () =>
            {
                var parameters = new AuthenticateRequestParameters(email, password.CreateSha512());
                coroutinesExecutor.StartTask((yield) => Authenticate(yield, parameters), exception => ServiceConnectionProviderUtils.OnOperationFailed());
            };

            if (LoginConnectionProvider.Instance.IsConnected())
            {
                authenticateAction.Invoke();
            }
            else
            {
                LoginConnectionProvider.Instance.Connect(onConnected: authenticateAction);
            }
        }
        public async Task <AuthenticateResponseParameters> Authenticate(IYield yield, AuthenticateRequestParameters parameters)
        {
            var responseParameters = await ServerPeerHandler.SendOperation <AuthenticateRequestParameters, AuthenticateResponseParameters>
                                         (yield, (byte)LoginOperations.Authenticate, parameters, MessageSendOptions.DefaultReliable());

            if (responseParameters.HasAccessToken)
            {
                AccessTokenProvider.AccessToken = responseParameters.AccessToken;
            }
            return(new AuthenticateResponseParameters(responseParameters.Status));
        }