Пример #1
0
        public IActionResult Login([FromBody] LoginModel loginModel)
        {
            try {
                LoginDAO loginDAO = new LoginDAO(_connection);
                var      user     = loginDAO.Authenticate(loginModel.Email, loginModel.Password);

                if (user == null)
                {
                    return(BadRequest(new ErrorMessageModel("Username ou password incorreto(s)")));
                }

                JwtTokenHelper tokenHelper = new JwtTokenHelper(_connection);
                ResponseTokens response    = tokenHelper.Authenticate(_secret, user);

                return(Ok(response));
            } catch (Exception e) {
                return(BadRequest(new ErrorMessageModel(e.Message)));
            }
        }