Skip to content

Commit

Permalink
[FEAT] apple login
Browse files Browse the repository at this point in the history
  • Loading branch information
leGit-y committed Oct 25, 2023
1 parent 517904a commit 6eb955f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
5 changes: 3 additions & 2 deletions src/controller/authController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,10 +141,11 @@ const kakaoLogin_getAuthorizedCode = async (req: Request, res: Response, next: N

const appleLogin =async (req: Request, res:Response, next:NextFunction) => {
try {
const { identityToken, user } = req.body
const { identityToken, user, fullName } = req.body
const DTO = {
identityToken: identityToken,
id: user
id: user,
fullName: fullName
}
const data = await authService.serviceLogin("apple", DTO);

Expand Down
14 changes: 7 additions & 7 deletions src/service/authService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ const serviceLogin = async (provider:string, user:any) => {
});

// 전달받은 identityToken이 변조되지 않은 올바른 토큰인지 확인하는 과정
const {identityToken, id} = user;
const {identityToken, id, fullName} = user;
const decoded = jwt.decode(identityToken, { complete: true})
const kid = decoded.header.kid

Expand All @@ -72,17 +72,17 @@ const serviceLogin = async (provider:string, user:any) => {

// 발급한 주체가(aud)가 우리의 서비스 id 와 일치하는지
// 사용자 식별 id 가 일치하는지
if(payload.sub === id && payload.aud === process.env.APPLE_CLIENT_ID){

if(payload.sub !== id || payload.aud !== process.env.APPLE_CLIENT_ID){
throw new ClientException("invliad signIn reqeust");
}

foundUser = await userService.getUserByAppleId(id);
if(!foundUser){

//필수 동의만 했을 경우
userCreateDTO.AppleId = id;
// userCreateDTO.name =


userCreateDTO.AppleId = id;
userCreateDTO.name = fullName;
userCreateDTO.email = payload.email;

//회원가입
const createdUser = await userService.createUser(userCreateDTO);
Expand Down

0 comments on commit 6eb955f

Please sign in to comment.