-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #204 from boostcampwm2023/feat/200-naver-login
[Feat] 네이버 로그인
- Loading branch information
Showing
9 changed files
with
142 additions
and
6 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import { Injectable, BadRequestException } from "@nestjs/common"; | ||
import { PassportStrategy } from "@nestjs/passport"; | ||
import { Profile, Strategy } from "passport-naver-v2"; | ||
import { User } from "../users.entity"; | ||
import { providerEnum } from "src/utils/enum"; | ||
|
||
@Injectable() | ||
export class NaverOAuthStrategy extends PassportStrategy(Strategy, "naver") { | ||
constructor() { | ||
super({ | ||
clientID: process.env.NAVER_CLIENT_ID, | ||
clientSecret: process.env.NAVER_CLIENT_PASS, | ||
callbackURL: `${process.env.BACKEND_URL}/auth/naver/callback`, | ||
}); | ||
} | ||
|
||
async validate( | ||
accessToken: string, | ||
refreshToken: string, | ||
profile: Profile, | ||
): Promise<User> { | ||
try { | ||
const { email, id, nickname } = profile; | ||
const user = new User(); | ||
|
||
user.email = email; | ||
user.userId = id + "*naver"; | ||
user.nickname = nickname; | ||
user.password = "naver"; | ||
user.provider = providerEnum.NAVER; | ||
|
||
return user; | ||
} catch (error) { | ||
throw new BadRequestException( | ||
`네이버 로그인 중 오류가 발생했습니다 : ${error.message}`, | ||
); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters