diff --git a/routes/users.js b/routes/users.js index 031e40d..54bd24c 100644 --- a/routes/users.js +++ b/routes/users.js @@ -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;