Commit 05ec1de9 authored by Jiwon Yoon's avatar Jiwon Yoon
Browse files

reservation/moviechart/moviecomming

parent 4517a35f
import jwt from "jsonwebtoken";
import config from "../config/app.config.js";
import { User, Role, Guest } from '../db/index.js';
import { User, Role, Guest, Reservation } from '../db/index.js';
import fs from "fs";
import CryptoJS from "crypto-js";
import axios from "axios";
......@@ -135,11 +135,11 @@ const confirmMbnum = async (req, res) => {
try {
const phoneNumber = req.params.phone;
console.log(phoneNumber);
//인증번호 생성
const verifyCode = Math.floor(Math.random() * (999999 - 100000)) + 100000;
console.log("verifyCode : ",verifyCode);
console.log("verifyCode : ", verifyCode);
let result = await axios({
method: method,
json: true,
......@@ -185,12 +185,12 @@ const confirmNum = async (req, res) => {
try {
const verifyCode = inherentNum;
const confirmNum = req.params.num;
if(!verifyCode){
if (!verifyCode) {
res.send("재전송")
}else{
} else {
if (confirmNum !== verifyCode) {
res.send("실패");
}else {
} else {
res.send("성공");
}
}
......@@ -222,7 +222,7 @@ const signup = async (req, res) => {
birth: userBirthday,
phoneNumber: userMbnum,
password: userPassword,
img:"",
img: "",
roleId: role.id
});
res.json(newUser);
......@@ -359,7 +359,7 @@ const getUserInfo = async (req, res) => {
try {
const userInfo = await User.findOne({
where: { id: id },
attributes: ["id","userId", "email", "nickname", "birth", "phoneNumber"]
attributes: ["id", "userId", "email", "nickname", "birth", "phoneNumber"]
})
console.log(userInfo)
res.json(userInfo)
......@@ -378,14 +378,38 @@ const saveGuestInfo = async (req, res) => {
phoneNumber: phoneNumber,
password: password,
});
// console.log(newGuest)
res.clearCookie(config.cookieName);
const token = jwt.sign({id: newGuest.id, role: "user"}, config.jwtSecret, {
expiresIn: config.jwtExpires,
});
res.cookie(config.cookieName,token , {
maxAge: config.cookieMaxAge,
path: "/",
httpOnly: config.env === "production",
secure: config.env === "production",
})
res.json(newGuest);
} catch (error) {
console.log(error)
res.status(500).send("비회원정보 등록 실패");
}
}
const getGuestInfo = async (req,res) => {
const {guestId} = req.params
// console.log(req.body)
try {
const guestInfo = await Guest.findOne({
where: {
id:guestId
}
})
// console.log("guestInfo====", guestInfo)
res.json(guestInfo)
} catch (error) {
res.status(500).send("비회원정보 불러오기 실패");
}
}
export default {
getUser,
login,
......@@ -399,5 +423,6 @@ export default {
saveGuestInfo,
getMember,
uploadProfile,
getUserInfo
getUserInfo,
getGuestInfo
}
......@@ -7,12 +7,9 @@ router
.route("/")
.get(movieCtrl.getListfromDB)
router
.route('/showmovies/:category')
.get(movieCtrl.getMovieById)
router
.route('/movielist')
.route('/movielist/:category')
.get(movieCtrl.getMovieList)
router
......@@ -38,6 +35,5 @@ router
.post(movieCtrl.create)
.delete(movieCtrl.remove)
router.param('category', movieCtrl.getMovieByCategory)
export default router;
\ No newline at end of file
......@@ -5,9 +5,13 @@ const router = express.Router();
router.route('/findreservation')
.post(ReservationCtrl.findReservation)
.post(ReservationCtrl.findReservedSeats)
.get(ReservationCtrl.findReservation)
router.route('/findonereservation')
.post(ReservationCtrl.findOneReservation)
router.route('/save')
.post(ReservationCtrl.saveReservation)
export default router;
\ No newline at end of file
......@@ -25,7 +25,7 @@ router
router
.post("/profile", upload.single("image"), userCtrl.uploadProfile)
router
.route("/modify")
.post(userCtrl.modifyUser)
......@@ -38,9 +38,6 @@ router
.route("/pw/:pw")
.get(userCtrl.comparePw)
router
.route("/:userId")
.get(userCtrl.compareId)
router
.route("/phone/:phone")
......@@ -56,4 +53,11 @@ router.route('/getuserinfo')
router.route('/guest/save')
.post(userCtrl.saveGuestInfo)
router.route('/guestinfo/:guestId')
.get(userCtrl.getGuestInfo)
router
.route("/:userId")
.get(userCtrl.compareId)
export default router;
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment