Beispiel #1
0
        public IActionResult Login(LoginModel model)
        {
            var applicationUser = _applicationUserService.GetApplicationUserByUsernameAndPassword(model.Username, model.Password);

            var token = _applicationUserService.GenerateJwtToken(applicationUser, _config.GetSection("Secret").ToString());

            _applicationUserService.AttachUserToContext(HttpContext, token);
            var response = new LoginResponseModel()
            {
                ApplicationUser = applicationUser, Token = token
            };

            return(Ok(response));
        }