public async Task <IActionResult> Login(LoginModal user)
        {
            var userDetail = await _auth.GetUser(user.Username, user.Password);

            if (userDetail == null)
            {
                return(Unauthorized());
            }

            var claims = new[]
            {
                new Claim(ClaimTypes.NameIdentifier, protector.Protect(userDetail.Id.ToString())),
                new Claim(ClaimTypes.Name, userDetail.Username),
                new Claim(ClaimTypes.GivenName, userDetail.Name),
            };

            var accessToken = _tokenService.GenerateAccessToken(claims);

            return(Ok(new {
                token = accessToken
            }));
        }
示例#2
0
        public IActionResult GetTestUser()
        {
            UserModel userModel = _authBL.GetUser("*****@*****.**");

            return(Ok(userModel));
        }