Skip to content

Commit

Permalink
Merge pull request #241 from hyeeyoung/dev-mod-user-tempNickname
Browse files Browse the repository at this point in the history
[mod] 임시 닉네임 로그인 처리 시 이미 닉네임이 있는 경우에는 null 보내도록 예외처리 추가
  • Loading branch information
hyejungg authored Jan 10, 2023
2 parents af3b214 + 00baf13 commit c3c8928
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/config/passport.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ async function localVerify(email, password, done) {
let user;
try {
const sqlSelect =
'SELECT user_id, email, password, is_active FROM users WHERE email = ?';
'SELECT user_id, email, password, nickname, is_active FROM users WHERE email = ?';

await db
.query(sqlSelect, email)
Expand Down
4 changes: 2 additions & 2 deletions src/controllers/authController.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ module.exports = {
});
}
const token = jwt.sign(user[0].user_id, process.env.JWT_SECRET_KEY);
const tempNickname = getRandomNickname();
const tempNickname = user[0].nickname ? null : getRandomNickname();
return res.status(StatusCode.OK).json({
success: true,
message: SuccessMessage.loginSuccess,
Expand Down Expand Up @@ -141,7 +141,7 @@ module.exports = {
if (isVerify) {
await User.signIn(req).then((result) => {
const token = jwt.sign(result[0].user_id, process.env.JWT_SECRET_KEY);
const tempNickname = getRandomNickname();
const tempNickname = result[0].nickname ? null : getRandomNickname();
return res.status(StatusCode.OK).json({
success: true,
message: SuccessMessage.loginSuccess,
Expand Down
2 changes: 1 addition & 1 deletion src/models/user.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ module.exports = {
const email = req.body.email;

const sqlSelect =
'SELECT user_id, email, push_state FROM users WHERE email = ? AND is_active = true';
'SELECT user_id, email, nickname, push_state FROM users WHERE email = ? AND is_active = true';

const [rows] = await db.query(sqlSelect, [email]);

Expand Down

0 comments on commit c3c8928

Please sign in to comment.