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

[fix] 카카오 redirect 수정 및 로그인 시 알림, 카테고리 에러 수정 #118

Merged
merged 2 commits into from
Feb 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 2 additions & 9 deletions src/controllers/kakao.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,8 @@ import { getKakaoUserInfo } from "../services/kakao.service";
export const kakaoLogin = async function(req, res) {
try {
const code = req.query.code;
let host = req.headers.host;
console.log(host);
if (host == 'vi-no.site') {
host = 'http://vi-no.site/social-account'
}
else {
host = 'https://www.vi-no.site/social-account'
}
const data = await getKakaoUserInfo(code, host);
const clientHost = req.headers['Client-host'];
const data = await getKakaoUserInfo(code, clientHost);
return res.status(200).json(data);
} catch(e) {
console.log(e);
Expand Down
8 changes: 7 additions & 1 deletion src/services/kakao.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export const getKakaoUserInfo = async function(code, host) {
grant_type: 'authorization_code',
client_id: process.env.KAKAO_CLIENT_ID,
code,
redirect_uri: host
redirect_uri: host+'/social-account'
}
});

Expand All @@ -39,6 +39,12 @@ export const getKakaoUserInfo = async function(code, host) {
nick_name: ''
};

const existingUser = await findUser(user.id); // 사용자가 이미 존재하는지 확인하는 함수
if (existingUser) { // 사용자가 이미 존재한다면,
const token = jwt.sign({ id: user.id }, process.env.JWT_SECRET);
return { status: 200, success: true, message: '로그인 성공', result: { token } };
}

const newUser = await createUserKakao(user);
const time = new Date;
const alarmdata={
Expand Down
Loading