Esempio n. 1
0
        private async Task <AuthenticationState> CreateAuthenticatedState(string accessToken)
        {
            UserInfo = UserInfoJwt.FromJwt(accessToken);
            var authenticatedUser = CreateClaimsPrincipal(UserInfo);

            return(await Task.FromResult(new AuthenticationState(authenticatedUser)));
        }
Esempio n. 2
0
        public IActionResult Login([FromBody] UserLogin userLogin)
        {
            var userInfo = AuthenticateUser(userLogin.UserName, userLogin.Password);

            if (userInfo != null)
            {
                var token = UserInfoJwt.ToJwt(userInfo, AuthOptions.Value);
                return(Ok(new { AccessToken = token }));
            }

            return(Unauthorized());
        }
        private string GenerateJwt(UserInfo userInfo)
        {
            var authOptions = configuration.GetSection("AuthOptions").Get <AuthOptions>();

            return(UserInfoJwt.ToJwt(userInfo, authOptions));
        }