Exemplo n.º 1
0
        public async Task <ApiResult> QQLogin(string code)
        {
            string accessToken = await QQClient.GetAccessToken(code);

            string openId = await QQClient.GetOpenId(accessToken);

            UserDTO userDTO = await QQClient.GetQQUser(accessToken, openId);

            _userService.CreateQQUser(userDTO);
            IList <Claim> claims = new List <Claim>()
            {
                new Claim("account", userDTO.Account),
                new Claim("username", userDTO.Username),
                new Claim("sex", userDTO.Sex),
                new Claim("birthDate", string.IsNullOrEmpty(userDTO.BirthDate)?"":userDTO.BirthDate),
                new Claim("email", string.IsNullOrEmpty(userDTO.Email)?"":userDTO.Email),
                new Claim("sign", string.IsNullOrEmpty(userDTO.Sign)?"":userDTO.Sign),
                new Claim("phone", string.IsNullOrEmpty(userDTO.Phone)?"":userDTO.Phone),
                new Claim("headPhoto", string.IsNullOrEmpty(userDTO.HeadPhoto)?"":userDTO.HeadPhoto)
            };
            string jwtToken = Auth.CreateToken(claims);

            return(ApiResult.Success(jwtToken));
        }