Пример #1
0
        public async void OnLogin()
        {
            if (this.IsBusy == true)
            {
                // Исключить повторную авторизации
                return;
            }

            if (!CheckUserInput())
            {
                return;
            }

            try
            {
                this.IsBusy = true;

                bool acceptSsl = sslSwitch.IsToggled;

                await App.Core.Connect(serverAddressInput.Text, loginInput.Text, passwordInput.Text, acceptSsl);

                this.IsBusy = false;

                SuccessLogin?.Invoke(this, EventArgs.Empty);
            }
            catch (Exception exc)
            {
                BugReportService.HandleException(Droid.Resources.Messages.LoginPage_Error_Connect_to_Server, exc.Message, exc);
            }
            finally
            {
                this.IsBusy = false;
            }
        }
Пример #2
0
        private async Task LoginAsync()
        {
            if (string.IsNullOrWhiteSpace(Login))
            {
                ShowToast("Login can't be empty");
                return;
            }

            if (string.IsNullOrWhiteSpace(Password))
            {
                ShowToast("Password can't be empty");
                return;
            }

            IsBusy = true;

            try
            {
                var result = await _authService.LoginAsync(Login, Password);

                if (!result.IsSuccess)
                {
                    ShowToast(result.GetFullMessage());
                    return;
                }

                SuccessLogin?.Invoke(this, EventArgs.Empty);
            }
            finally
            {
                IsBusy = false;
            }
        }
Пример #3
0
        protected override async void OnAppearing()
        {
            if (!string.IsNullOrEmpty(AppDataStorage.Uri) && !string.IsNullOrEmpty(AppDataStorage.Token))
            {
                this.IsBusy = true;
                this.onLoginButton.IsEnabled = false;

                try
                {
                    // Скрываем логин и пароль, так как мы входим по токену.
                    ShowPasswordControls(false);

                    await this.coreService.ConnectToken(AppDataStorage.Uri, AppDataStorage.Token);

                    SuccessLogin?.Invoke(this, EventArgs.Empty);
                }
                catch (Exception exc)
                {
                    // Произошла ошибка входа, попробуем войти с помощью логина и пароля.

                    ShowPasswordControls(true);

                    BugReportService.HandleException(Droid.Resources.Messages.LoginPage_Error_Connect, exc.Message, exc);
                }
                finally
                {
                    this.IsBusy = false;
                    this.onLoginButton.IsEnabled = true;
                }
            }
        }
Пример #4
0
 private void _onLogin(LoginInfo loginInfo)
 {
     if (loginInfo.IsLogin)
     {
         MyInfo.PlayerID = loginInfo.PlayerID;
         SuccessLogin?.Invoke(this, EventArgs.Empty);
     }
     FailLogin?.Invoke(this, EventArgs.Empty);
 }