From a8480549c062a6ae6744a3865657bc5b2c68013e Mon Sep 17 00:00:00 2001 From: Arios67 Date: Fri, 1 Apr 2022 23:04:13 +0900 Subject: [PATCH] =?UTF-8?q?[#114]feat:=20=EC=86=8C=EC=85=9C=20=EB=A1=9C?= =?UTF-8?q?=EA=B7=B8=EC=9D=B8=20=EC=9C=A0=EC=A0=80=20=EC=A0=95=EB=B3=B4=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ars/src/apis/auth/auth.service.ts | 9 +++++++-- ars/src/apis/user/user.resolver.ts | 12 ++++++++---- ars/src/common/graphql/schema.gql | 2 +- 3 files changed, 16 insertions(+), 7 deletions(-) diff --git a/ars/src/apis/auth/auth.service.ts b/ars/src/apis/auth/auth.service.ts index 630116a..c4026a9 100644 --- a/ars/src/apis/auth/auth.service.ts +++ b/ars/src/apis/auth/auth.service.ts @@ -30,19 +30,24 @@ export class AuthService { } async loginOAuth(req, res) { - let user = await this.userService.findOne({ email: req.user.email }); - + let email = req.user.email; + console.log(email + '****************!!'); + let user = await this.userService.findOne(email); + console.log('LLLLLLOOOOOO !' + user); if (!user) { const { password, ...rest } = req.user; const hashedPassword = await bcrypt.hash(String(password), 1); const createUser = { ...rest, password: hashedPassword }; user = await this.userService.create({ ...createUser }); this.setRefreshToken({ user, res }); + console.log('user created !!!'); res.redirect('https://artipul.shop/socialLogin'); + return user; } else { this.setRefreshToken({ user, res }); res.redirect('https://artipul.shop/'); res.send(user); + return user; } } } diff --git a/ars/src/apis/user/user.resolver.ts b/ars/src/apis/user/user.resolver.ts index 3a929b1..bf76125 100644 --- a/ars/src/apis/user/user.resolver.ts +++ b/ars/src/apis/user/user.resolver.ts @@ -4,7 +4,10 @@ import { User } from './entities/user.entity'; import { UserService } from './user.service'; import * as bcrypt from 'bcrypt'; import { UseGuards } from '@nestjs/common'; -import { GqlAuthAccessGuard } from 'src/common/auth/gql-auth.guard'; +import { + GqlAuthAccessGuard, + GqlAuthRefreshGuard, +} from 'src/common/auth/gql-auth.guard'; import { CurrentUser, ICurrentUser } from 'src/common/auth/gql-user.param'; import { UpdateSocialUser } from './dto/updateSocialUserInput'; @@ -23,9 +26,10 @@ export class UserResolver { return await this.userService.findUserEmail({ phoneNum }); } - @Query(() => String) - async findSocialUser(@Args('email') email: string) { - const user = await this.userService.findOne(email); + @UseGuards(GqlAuthRefreshGuard) + @Query(() => User) + async findSocialUser(@CurrentUser() currentUser: ICurrentUser) { + return await this.userService.findOne(currentUser.email); } @Mutation(() => User) diff --git a/ars/src/common/graphql/schema.gql b/ars/src/common/graphql/schema.gql index 435b7f2..2fd8c4f 100644 --- a/ars/src/common/graphql/schema.gql +++ b/ars/src/common/graphql/schema.gql @@ -163,7 +163,7 @@ type Query { fetchArtistProfile(artId: String!): Profile! fetchUser: User! findUserEmail(phoneNum: String!): String! - findSocialUser(email: String!): String! + findSocialUser: User! fetchPointTransactions: [PointTransaction!]! }