Beispiel #1
0
        public IActionResult Login(User login)
        {
            try
            {
                IActionResult response = Unauthorized();

                var user = _Authen.AuthenticateUser(login);
                if (user != null)
                {
                    var tokenStr = _Authen.GennerateJSONWebToken(user);
                    response = Ok(new { token = tokenStr });
                }

                return(response);
            }
            catch (Exception)
            {
                return(BadRequest());
            }
        }