diff --git a/ars/src/apis/auth/auth.controller.ts b/ars/src/apis/auth/auth.controller.ts index 1ce4db3..752b736 100644 --- a/ars/src/apis/auth/auth.controller.ts +++ b/ars/src/apis/auth/auth.controller.ts @@ -18,7 +18,7 @@ export class AuthController { @Req() req: Request & IOAuthUser, // @Res() res: Response, ) { - this.authService.loginOAuth(req, res); + await this.authService.loginOAuth(req, res); } @Get('/login/kakao') @@ -27,6 +27,6 @@ export class AuthController { @Req() req: Request & IOAuthUser, // @Res() res: Response, ) { - this.authService.loginOAuth(req, res); + await this.authService.loginOAuth(req, res); } } diff --git a/ars/src/apis/auth/auth.service.ts b/ars/src/apis/auth/auth.service.ts index 270afbe..1c2b4e8 100644 --- a/ars/src/apis/auth/auth.service.ts +++ b/ars/src/apis/auth/auth.service.ts @@ -37,9 +37,11 @@ export class AuthService { const hashedPassword = await bcrypt.hash(String(password), 1); const createUser = { ...rest, password: hashedPassword }; user = await this.userService.create({ ...createUser }); + this.setRefreshToken({ user, res }); + res.redirect('http://localhost:3000/socialLogin'); + } else { + this.setRefreshToken({ user, res }); + res.redirect('http://localhost:3000'); } - - this.setRefreshToken({ user, res }); - res.redirect('http://localhost:5500/frontend/login/index.html'); } } diff --git a/ars/src/apis/user/dto/updateSocialUserInput.ts b/ars/src/apis/user/dto/updateSocialUserInput.ts new file mode 100644 index 0000000..68de2f2 --- /dev/null +++ b/ars/src/apis/user/dto/updateSocialUserInput.ts @@ -0,0 +1,19 @@ +import { Field, InputType } from '@nestjs/graphql'; + +@InputType() +export class UpdateSocialUser { + @Field(() => String) + email: string; + + @Field(() => String) + nickname: string; + + @Field(() => String) + phoneNum: string; + + @Field(() => Boolean) + is_artist: boolean; + + @Field(() => String, { nullable: true }) + college?: string; +} diff --git a/ars/src/apis/user/user.resolver.ts b/ars/src/apis/user/user.resolver.ts index 932a724..5ff9f93 100644 --- a/ars/src/apis/user/user.resolver.ts +++ b/ars/src/apis/user/user.resolver.ts @@ -6,6 +6,7 @@ import * as bcrypt from 'bcrypt'; import { UseGuards } from '@nestjs/common'; import { GqlAuthAccessGuard } from 'src/common/auth/gql-auth.guard'; import { CurrentUser, ICurrentUser } from 'src/common/auth/gql-user.param'; +import { UpdateSocialUser } from './dto/updateSocialUserInput'; @Resolver() export class UserResolver { @@ -33,6 +34,15 @@ export class UserResolver { return await this.userService.create({ hashedPassword, ...rest }); } + @Mutation(() => User) + async updateSocialUser( + @Args('updateSocialUser') updateSocialUser: UpdateSocialUser, + ) { + return await this.userService.updateSocialUser({ + ...updateSocialUser, + }); + } + @Mutation(() => String) async sendPhoneToken(@Args('phoneNum') phoneNum: string) { if (phoneNum.length !== 10 && phoneNum.length !== 11) { diff --git a/ars/src/apis/user/user.service.ts b/ars/src/apis/user/user.service.ts index 243a27b..aaf5835 100644 --- a/ars/src/apis/user/user.service.ts +++ b/ars/src/apis/user/user.service.ts @@ -82,6 +82,14 @@ export class UserService { } } + async updateSocialUser({ email, ...rest }) { + const user = await this.userRepository.findOne({ email }); + return await this.userRepository.save({ + ...user, + ...rest, + }); + } + async sendTokenTOSMS(phoneNum, token) { try { const appKey = process.env.SMS_APP_KEY; diff --git a/ars/src/common/graphql/schema.gql b/ars/src/common/graphql/schema.gql index f9896b6..28ef128 100644 --- a/ars/src/common/graphql/schema.gql +++ b/ars/src/common/graphql/schema.gql @@ -168,6 +168,7 @@ type Mutation { deleteComment(commentId: String!): Boolean! createProfile(createProfileInput: CreateProfileInput!): Profile! createUser(createUserInput: CreateUserInput!): User! + updateSocialUser(updateSocialUser: UpdateSocialUser!): User! sendPhoneToken(phoneNum: String!): String! phoneAuth(phoneNum: String!, token: String!): Boolean! checkNickname(nickname: String!): Boolean! @@ -225,3 +226,11 @@ input CreateUserInput { is_artist: Boolean! college: String } + +input UpdateSocialUser { + email: String! + nickname: String! + phoneNum: String! + is_artist: Boolean! + college: String +} diff --git a/frontend/login/index.html b/frontend/login/index.html index 8c0defe..3c9047a 100644 --- a/frontend/login/index.html +++ b/frontend/login/index.html @@ -21,23 +21,25 @@ 구글로 로그인
- 네이버로 로그인 + href="http://daseul.shop/login/naver" + >네이버로 로그인
- 카카오톡으로 로그인 + >카카오톡으로 로그인