示例#1
0
        public async Task <ActionResult> AuthenticateAsync([FromBody] IdToken idToken)
        {
            var user = _jwtAuthManager.GoogleVerification(idToken);

            if (user == null)
            {
                return(BadRequest());
            }

            user.Name = idToken.User;
            await _userRepo.CreateUser(user);

            var jwtToken = _jwtAuthManager.Authenticate(user.Sub, user.Email);

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

            return(Ok(jwtToken));
        }