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

#514 랜덤 이메일 업데이트 #515

Merged
merged 5 commits into from
May 21, 2024
Merged
Changes from 4 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
15 changes: 12 additions & 3 deletions src/services/auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,21 +58,30 @@ const joinus = async (req, userData) => {
};

const update = async (userData) => {
const updateInfo = { name: userData.name };
const updateInfo = {
name: userData.name,
email: userData.email,
"subinfo.kaist": userData.kaist,
};
await userModel.updateOne({ id: userData.id }, updateInfo);
logger.info(`Update user info: ${userData.id}`);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

기존 값이랑 새로운 값이 모두 로그에 남으면 좋겠습니다!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

아 네네 알겠습니다!

};

const tryLogin = async (req, res, userData, redirectOrigin, redirectPath) => {
try {
const user = await userModel.findOne(
{ id: userData.id },
"_id name id withdraw ban"
"_id name email subinfo id withdraw ban"
);
if (!user) {
await joinus(req, userData);
return tryLogin(req, res, userData, redirectOrigin, redirectPath);
}
if (user.name != userData.name) {
if (
user.name !== userData.name ||
user.email !== userData.email ||
user.subinfo.kaist !== userData.kaist
) {
await update(userData);
return tryLogin(req, res, userData, redirectOrigin, redirectPath);
}
Expand Down
Loading