Beispiel #1
0
        private void okCommand_Click(object sender, EventArgs e)
        {
            retryCount += 1;

            // If the user tries more than three times then they must restart the app
            if (retryCount > 3)
            {
                Application.Exit();
            }


            if (userTextEdit.Text == string.Empty)
            {
                errorProvider1.SetError(userTextEdit, "User name is required");
                return;
            }

            var user     = userTextEdit.Text;
            var password = passwordTextEdit.Text;

            try
            {
                if (SecurityHelper.Authenticate(user, password))
                {
                    var shell = new MainForm();
                    shell.Show();
                    this.Hide();
                }
            }
            catch (ApplicationException exception)
            {
                ViewHelper.ShowErrorMessage(exception.Message);
            }
        }
Beispiel #2
0
 protected void btnOpenIdLogin_LoggedIn(object sender, OpenIdEventArgs e)
 {
     e.Cancel = true;
     if (e.Response.Status == AuthenticationStatus.Authenticated &&
         SecurityHelper.Authenticate(e.ClaimedIdentifier, btnOpenIdLogin.RememberMe))
     {
         ReturnToUrl(AdminUrl.Home());
     }
     else
     {
         openIdMessage.Text = Resources.Login_AuthenticationFailed;
     }
 }
Beispiel #3
0
 public JsonResult AlterarSenha(AlterarSenhaViewModel viewModel)
 {
     if (SecurityHelper.Authenticate(User.ToPessoa().Usuario.NomeDeUsuario, viewModel.Senha))
     {
         var requisicao = new AlterarSenhaRequisicao
         {
             CodigoDaPessoa = User.ToPessoa().Codigo,
             NovaSenha      = viewModel.NovaSenha
         };
         var resposta = _pessoaServicoDeAplicacao.AlterarSenha(requisicao);
         return(Json(resposta));
     }
     return(Json(new { Sucesso = false }));
 }
Beispiel #4
0
        private void btnLogin_Click(object sender, EventArgs e)
        {
            string username = this.txtUsername.Text;
            string password = this.txtPassword.Text;

            bool authenticated;

            authenticated = SecurityHelper.Authenticate(username, password);

            if (authenticated == true)
            {
                this.DialogResult = DialogResult.OK;
            }
            else
            {
                this.errorLabel.Visible = true;
            }
        }
Beispiel #5
0
 public ActionResult Login(LoginViewModel model)
 {
     try
     {
         if (SecurityHelper.Authenticate(model.NomeDeUsuario, model.Senha))
         {
             FormsAuthentication.SetAuthCookie(model.NomeDeUsuario, model.Relembrar);
             var pessoa = _pessoaServicoDeAplicacao.RegistrarAcesso(model.NomeDeUsuario);
             Session.SetProgramaAtivo(pessoa.ProgramasPermitidos[0]);
             return(Redirect(string.IsNullOrWhiteSpace(model.ReturnUrl) ? Url.Action("Index", "Relatorios") : model.ReturnUrl));
         }
     }
     catch (Exception exception)
     {
         ViewBag.HasError = true;
         Error(exception.Message);
     }
     return(View(model));
 }