diff --git a/BE/src/auth/auth.module.ts b/BE/src/auth/auth.module.ts index 9291a81..409052d 100644 --- a/BE/src/auth/auth.module.ts +++ b/BE/src/auth/auth.module.ts @@ -19,9 +19,6 @@ import { NaverOAuthStrategy } from "./strategies/naver.strategy"; PassportModule.register({ defaultStrategy: "jwt" }), JwtModule.register({ secret: process.env.JWT_SECRET, - signOptions: { - expiresIn: process.env.JWT_ACCESS_TOKEN_TIME, - }, }), ], controllers: [AuthController], diff --git a/BE/src/auth/auth.service.ts b/BE/src/auth/auth.service.ts index 8691cfa..08eedca 100644 --- a/BE/src/auth/auth.service.ts +++ b/BE/src/auth/auth.service.ts @@ -37,7 +37,7 @@ export class AuthService { throw new NotFoundException("올바르지 않은 비밀번호입니다."); } - return this.createUserTokens(userId, request.ip); + return this.createUserTokens(userId, user.nickname, request.ip); } async signOut(user: User): Promise { @@ -53,7 +53,10 @@ export class AuthService { const expiredResult = JSON.parse(payload.toString()); const userId = expiredResult.userId; - return this.createUserTokens(userId, request.ip); + + const userNickname = (await User.findOne({ where: { userId: userId } })) + .nickname; + return this.createUserTokens(userId, userNickname, request.ip); } async naverSignIn(user: User, request: Request): Promise { @@ -64,7 +67,7 @@ export class AuthService { await user.save(); } - return this.createUserTokens(userId, request.ip); + return this.createUserTokens(userId, user.nickname, request.ip); } async kakaoSignIn(user: User, request: Request): Promise { @@ -75,11 +78,12 @@ export class AuthService { await user.save(); } - return this.createUserTokens(userId, request.ip); + return this.createUserTokens(userId, user.nickname, request.ip); } private async createUserTokens( userId: string, + nickname: string, requestIp: string, ): Promise { const accessTokenPayload = { userId }; @@ -98,6 +102,6 @@ export class AuthService { // 86000s = 24h await this.redisClient.set(userId, refreshToken, "EX", 86400); - return new AccessTokenDto(accessToken); + return new AccessTokenDto(accessToken, nickname); } } diff --git a/BE/src/auth/dto/auth-access-token.dto.ts b/BE/src/auth/dto/auth-access-token.dto.ts index d853cf7..9884334 100644 --- a/BE/src/auth/dto/auth-access-token.dto.ts +++ b/BE/src/auth/dto/auth-access-token.dto.ts @@ -1,7 +1,9 @@ export class AccessTokenDto { accessToken: string; + nickname: string; - constructor(accessToken: string) { + constructor(accessToken: string, nickname: string) { this.accessToken = accessToken; + this.nickname = nickname; } }