public async Task LoginTest()
        {
            LoginResultViewmodel result = await _authenticationLogic.Login(new TestLogin().Login);

            Assert.AreNotEqual(new LoginResultViewmodel(), result);
            Assert.NotNull(result.RefreshToken);
            Assert.NotNull(result.Jwt);
        }
Ejemplo n.º 2
0
 private void LoginForm_KeyDown(object sender, KeyEventArgs e)
 {
     if (e.KeyCode == Keys.Enter)
     {
         var success = AuthenticationLogic.Login(txtUserName.Text, txtPassword.Text);
         DisableFields();
     }
 }
Ejemplo n.º 3
0
        private void btnLogin_Click(object sender, EventArgs e)
        {
            //txtUserName.Text = "master";
            //txtPassword.Text = "123456";
            var response = AuthenticationLogic.Login(txtUserName.Text, txtPassword.Text, OnLoginSuccess, OnLoginFailed);

            DisableFields();
        }
        public async Task <IActionResult> Login([FromBody] LoginModel model)
        {
            if (ModelState.IsValid)
            {
                LoginResponse res = await AuthenticationLogic.Login(userManager, model);
                await Authenticate(res.claims, res.RememberMe);

                if (res.success)
                {
                    return(Ok(res));
                }
                else
                {
                    return(Unauthorized());
                }
            }
            else
            {
                return(BadRequest("Invalid Login Model"));
            }
        }
        public async Task <ActionResult> Login([FromBody] Login login)
        {
            try
            {
                LoginResultViewmodel result = await _authorizationLogic.Login(login);

                return(Ok(result));
            }
            catch (UnauthorizedAccessException)
            {
                return(Unauthorized());
            }
            catch (DisabledUserException)
            {
                return(Forbid());
            }
            catch (Exception e)
            {
                _logLogic.Log(e);
                return(StatusCode(StatusCodes.Status500InternalServerError));
            }
        }