예제 #1
0
        public async void Logon(object parameter)
        {
            Message = "Logging in...";
            // This breaks MVVM, but you can't bind to the password in a password
            // box for security reasons
            var pass = parameter as PasswordBox;

            if (pass == null)
            {
                return;
            }

            _view.IsEnabled = false;

            try
            {
                // This will throw if authentication fails
                await GitHubApi.Login(Username, pass.Password, AccessToken);

                _view.Close();
            }
            catch (Exception e)
            {
                _view.IsEnabled = true;
                Message         = "Logon failed. " + e.Message;
            }
        }
예제 #2
0
 private void OnConnectionRequested(object sender, EventArgs e)
 {
     if (_view.Login == "demo")
     {
         _view.Close();
         _formOpener.ShowModalForm <MainView>();
     }
     else if (!string.IsNullOrEmpty(_view.Login) && !string.IsNullOrEmpty(_view.Password))
     {
         Constant.CurrentEmploye = new EmployeDataService(_cache, _serializer, _errorLogger).Authenticate(new Employe(_view.Login, _view.Password));
         if (Constant.CurrentEmploye != null && Constant.CurrentEmploye.AuthKey != "")
         {
             _view.Close();
             _formOpener.ShowModalForm <MainView>();
         }
     }
 }
예제 #3
0
        private void LoginEventHandler(string answer)
        {
            if (answer == "OK")
            {
                _kernel.Get <MainPresenter>().Run();
                _view.Close();
            }

            if (answer == "ERROR")
            {
                _view.ShowErrorMessage("Неверный логин и/или пароль");
            }
        }
예제 #4
0
        public void LogIn(object sender, EventArgs e)
        {
            if (_view.GetLogin().Replace(" ", "").Length == 0 || _view.GetPassword().Replace(" ", "").Length == 0)
            {
                _view.ShowEmpty();
                return;
            }

            if (_model.Authorization(_view.GetLogin(), _view.GetPassword()))
            {
                Global.Login = _view.GetLogin();
                _view.Close();
            }
            else
            {
                _view.ShowError();
            }
        }