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 e89ded4..291b22d 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!]! }