示例#1
0
        public IActionResult Login([FromBody] LoginDto login)
        {
            if (login == null)
            {
                return(BadRequest(ModelState));
            }

            login.Password = _securityProvider.CalculateSha256(login.Password);

            UserDto user = _userService.ValidateUser(login);

            if (user != null)
            {
                String token = _jwtService.GenerateToken(user.Id, user.Email, user.Name);

                return(Ok(new { Token = token }));
            }
            else
            {
                return(BadRequest("Неверный email или пароль"));
            }
        }