-
Notifications
You must be signed in to change notification settings - Fork 3
[Feat] 회원가입/로그인/로그아웃 API 구현 #46
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
@jjeonghak |
PMtHk
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
수고하셨습니다.
뷰 작업도 힘을 좀 내야겠군요!
| import { Account } from '../entity/account.entity'; | ||
|
|
||
| @Injectable() | ||
| export class AccountService { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
❓
AccountService 는 AccountRepository 의 Wrapper 클래스로 사용하신 건가요?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
아직 Account에 별다른 정보와 기능이 없어서 지금은 래퍼 클래스라고 봐도 무방한 것 같습니다. authService랑 분리를 일단 해두었는데 이후에도 별다른 기능이 없다면 사실 통합해도 될 것 같이요
iam454
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
빠..빠르다..!
(끄응 솔직히 nest 코드 잘 모르겠습니다.. ㅠㅠ)
| throw new UnauthorizedException('Invalid refresh token'); | ||
| } | ||
| const accessToken = await this.generateAccessToken({ id: user.id, username: user.username }); | ||
| return { accessToken, refreshToken }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
access 토큰 재발급 로직에서 refresh 토큰은 재발급 하지 않아도 괜찮을까요 ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
access 토큰은 재발급하고, refresh 토큰이 만료되면 다시 로그인해야하는 로직으로 구현했습니다
| private generateAccessToken(payload: { id: number; username: string }) { | ||
| return this.jwtService.signAsync(payload, { | ||
| secret: this.configService.get<string>('JWT_ACCESS_TOKEN_SECRET'), | ||
| expiresIn: this.configService.get<string>('JWT_ACCESS_TOKEN_TIME'), | ||
| }); | ||
| } | ||
|
|
||
| private generateRefreshToken(payload: { id: number; username: string }) { | ||
| return this.jwtService.signAsync(payload, { | ||
| secret: this.configService.get<string>('JWT_REFRESH_TOKEN_SECRET'), | ||
| expiresIn: this.configService.get<string>('JWT_REFRESH_TOKEN_TIME'), | ||
| }); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
토큰 생성 로직은 별도 클래스로 분리하는 것도 괜찮을 것 같아요 !
관련 이슈 번호
#26 #23 #30
작업 내용
고민과 학습내용
로그인 관련 작업을 일단 간단하게 구현해보았습니다.
Authoriaztion헤더와X-Refresh-Toekn헤더에 jwt 토큰을 이용해서 처리하는 방식입니다.