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 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
20 changes: 17 additions & 3 deletions src/services/auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,22 +58,36 @@ 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} ${userData.name} ${userData.email} ${userData.kaist}`
);
};

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);
logger.info(
`Past user info: ${user.id} ${user.name} ${user.email} ${user.subinfo.kaist}`
);
return tryLogin(req, res, userData, redirectOrigin, redirectPath);
}

Expand Down
Loading