HOT_FIX : 중복 유저 검사시 username으로 잘못 검색하던 이슈 수정
- DB findOne 검사 조건 수정 - 유저 데이터에 코인 정보 추가
This commit is contained in:
parent
87d2b03329
commit
6cc00098f9
@ -5,7 +5,7 @@ const {ObjectId} = require("mongodb");
|
||||
var saltRounds = 10;
|
||||
|
||||
var ResponseType = {
|
||||
INVALID_USERNAME: 0,
|
||||
INVALID_EMAIL: 0,
|
||||
INVALID_PASSWORD: 1,
|
||||
SUCCESS: 2
|
||||
}
|
||||
@ -37,7 +37,7 @@ router.post('/signup', async function (req, res, next) {
|
||||
|
||||
var database = req.app.get('database');
|
||||
var users = database.collection('users');
|
||||
const existingUser = await users.findOne({username: email})
|
||||
const existingUser = await users.findOne({email: email})
|
||||
if(existingUser){
|
||||
return res.status(409).send("이미 존재하는 사용자입니다.")
|
||||
}
|
||||
@ -55,7 +55,8 @@ router.post('/signup', async function (req, res, next) {
|
||||
rating: 18,
|
||||
score:0,
|
||||
win:0,
|
||||
lose:0
|
||||
lose:0,
|
||||
coin: 1000
|
||||
});
|
||||
|
||||
res.status(201).send("사용자가 성공적으로 생성되었습니다.");
|
||||
@ -90,18 +91,20 @@ router.post("/signin", async function (req, res, next) {
|
||||
req.session.profileImageIndex = existingUser.profileImageIndex || 0;
|
||||
req.session.rating = existingUser.rating;
|
||||
req.session.score = existingUser.score;
|
||||
req.session.coin = existingUser.coin;
|
||||
|
||||
res.json({
|
||||
result: ResponseType.SUCCESS,
|
||||
imageindex: existingUser.imageindex,
|
||||
rating: existingUser.rating,
|
||||
score: existingUser.score,
|
||||
coin: existingUser.coin,
|
||||
});
|
||||
} else {
|
||||
res.json({result : ResponseType.INVALID_PASSWORD});
|
||||
}
|
||||
} else {
|
||||
res.json({result : ResponseType.INVALID_USERNAME});
|
||||
res.json({result : ResponseType.INVALID_EMAIL});
|
||||
}
|
||||
}catch (err){
|
||||
console.log("로그인 중 오류 발생 : ", err);
|
||||
@ -246,4 +249,9 @@ router.get("/get-info", async function (req, res, next) {
|
||||
}
|
||||
})
|
||||
|
||||
router.put("/coin/:id", async function (req, res, next) {
|
||||
|
||||
})
|
||||
|
||||
|
||||
module.exports = router;
|
||||
|
Loading…
x
Reference in New Issue
Block a user