Exemple #1
0
        public IActionResult Authenticate([FromBody] AuthRequest authRequest)
        {
            var user = _userService.FindUserByUsernameAndPassword(authRequest.Username, authRequest.Password);

            if (user == null)
            {
                return(new UnauthorizedResult());
            }
            var token = GenerateToken.TokenGeneration(user);

            return(new JsonResult(new AuthResponse(user.Id.ToString(), token)));
        }