Пример #1
0
        private async Task <AuthenticationState> CreateAuthenticatedState(string accessToken)
        {
            UserInfo = UserInfoJwt.FromJwt(accessToken);
            var authenticatedUser = CreateClaimsPrincipal(UserInfo);

            return(await Task.FromResult(new AuthenticationState(authenticatedUser)));
        }
Пример #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());
        }
Пример #3
0
        private string GenerateJwt(UserInfo userInfo)
        {
            var authOptions = configuration.GetSection("AuthOptions").Get <AuthOptions>();

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