Skip to content
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

Auth 반환값 #112

Open
9utty opened this issue Mar 27, 2023 · 1 comment
Open

Auth 반환값 #112

9utty opened this issue Mar 27, 2023 · 1 comment
Assignees

Comments

@9utty
Copy link
Member

9utty commented Mar 27, 2023

  async login(request: Request, response: Response): Promise<TokenDto> {
    let user: User = await this.getUserFromGoogleUser(request)
    // 회원가입 필요하면 회원가입으로 넘김
    if (user === undefined || user === null) {
      user = await this.signup(request, response)
    }
    const userId: number = user.userId
    const accessToken: string = this.getNewAccessToken(userId)
    const refreshToken: string = this.getRefreshToken(userId)

    await this.deleteSession(userId)
    await this.createSession(userId, accessToken, refreshToken)
    return {
      accessToken: accessToken,
      refreshToken: refreshToken,
    }
  }

성공적으로 로그인이 완료가 되었을때 현재 accessToken, refreshToken 이 리턴이 됩니다!
프론트에서 global 로 현재 로그인 되어 있는 유저의 uid를 가지고 있어야해서 토큰들과 userId가
필요합니다! 여러가지로 myProfile이라던지 이런것들을 확인해야하는 과정이 필요해서
global로 Uid를 가지고 있어야 합니다 ㅎㅎ

@koreanddinghwan
Copy link
Contributor

@Get('/redirect/google-login')
@UseGuards(GoogleLoginGuard)
async redirectGoogleLogin(
@Req() request: Request,
@Res({ passthrough: true }) response: Response
): Promise<TokenDto> {
return await this.authService.login(request, response)
}

return 값에 userId만 같이 리턴하면 될 것 같습니다.

await this.deleteSession(userId)
    await this.createSession(userId, accessToken, refreshToken)
    return {
      userId,
      accessToken: accessToken,
      refreshToken: refreshToken,
    }

koreanddinghwan added a commit that referenced this issue Mar 30, 2023
refactor: #112 코드 수정 auth Dto 포함 해서 uid같이 반환하게 수정완료
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants