示例#1
0
        public async Task <IActionResult> Login([FromBody] AccountModel userData)
        {
            var currentUser = _databaseServices.GetUser(userData.Username);

            if (currentUser == null)
            {
                return(BadRequest("User is not set."));
            }

            if (!_securityServices.ValidatePassword(userData.Password, currentUser.PassHash))
            {
                return(BadRequest("Wrong password"));
            }

            var userToken = new ResultToken
            {
                AccesToken = await _redisRepository.Get(currentUser.TokenKey)
            };

            return(Ok(userToken));
        }