예제 #1
0
        public async Task <IActionResult> Login([FromBody] UserForLoginDto userForLogin)
        {
            // Call the Login from the repo
            var userModel = await _authRepository.LoginAsync(userForLogin.Username, userForLogin.Password);

            if (userModel?.Id == null)
            {
                return(Unauthorized());
            }

            // Generate Token from Request
            TokenString.GenerateTokenString(userModel.Id.ToString(), userModel.Username, _tokenKey, out string tokenString);

            return(Ok(new { tokenString }));
        }