diff --git a/server/src/controllers/userController.js b/server/src/controllers/userController.js index 4aded848badf32e9e9f7c1aa72336335231b532f..380df4fa4d6a9ac73641c60fdd02854be21951c9 100644 --- a/server/src/controllers/userController.js +++ b/server/src/controllers/userController.js @@ -54,8 +54,8 @@ export const getLogin = (req, res) => { }; // Page for Development Test. -export const getSetLoccode = (req, res) => { - res.render("setLoccode", { pagename: "Set Loccode" }); +export const getEditProfile = (req, res) => { + res.render("edit-profile", { pagename: "Edit Profile" }); }; // 회원 가입 처리 @@ -170,46 +170,20 @@ export const getUserInfo = async (req, res) => { }; // 사용자 정보 수정 요청 처리 -export const postEditProfile = (req, res) => { +export const postEditProfile = async (req, res) => { const { cookies: { acs_token }, - } = req; - - // 수신한 변경 내용들을 통해 DB Update. - - res - .status(server_status.code.ok) - .json({ msg: server_status.msg.ok, content: "Server OK" }); -}; - -// 사용자의 지역 코드 설정 처리 -export const postSetLoccode = async (req, res) => { - const { - cookies: { acs_token }, - body: { loccode }, + body: { nick_name, loc_code }, } = req; const decoded = jwt.decode(acs_token); await db.User.update( - { loc_code: Number(loccode) }, - { where: { email: decoded.email }, logging: false } + { nick_name: nick_name, loc_code: loc_code }, + { where: { email: decoded.email } } ); - const payload = { - email: decoded.email, - nick_name: decoded.nick_name, - loc_code: loccode, - }; - - const accessT = jwt.sign(payload, envs.secretKey.access_token, { - expiresIn: "14d", - issuer: "eue.com", - subject: "userInfo", - }); - res .status(server_status.code.ok) - .cookie("acs_token", accessT) - .json({ msg: server_status.msg.ok, content: "Successfully Set Loccode" }); + .json({ msg: server_status.msg.ok, content: "Update Successfully" }); }; diff --git a/server/src/routers/globalRouter.js b/server/src/routers/globalRouter.js index bf814e251d0f7c052780005b2f9741bcc47a8aa4..5fcf1c9c4ad6a200cb4455b019a859b303e6c6e8 100644 --- a/server/src/routers/globalRouter.js +++ b/server/src/routers/globalRouter.js @@ -3,13 +3,12 @@ import routes from "../routes"; import { getHome } from "../controllers/globalController"; import { getConfirm, + getEditProfile, getLogin, - getSetLoccode, getSignup, getUserInfo, postEditProfile, postLogin, - postSetLoccode, postSignup, } from "../controllers/userController"; import { onlyPrivate } from "../middlewares"; @@ -20,7 +19,7 @@ const globalRouter = express.Router(); globalRouter.get("/", getHome); globalRouter.get(routes.signup, getSignup); globalRouter.get(routes.login, getLogin); -globalRouter.get(routes.setLoccode, onlyPrivate, getSetLoccode); +globalRouter.get(routes.editProfile, onlyPrivate, getEditProfile); // Authentication globalRouter.post(routes.signup, postSignup); @@ -30,6 +29,5 @@ globalRouter.get(routes.confirm, getConfirm); // User Info globalRouter.get(routes.userinfo, onlyPrivate, getUserInfo); globalRouter.post(routes.editProfile, onlyPrivate, postEditProfile); -globalRouter.post(routes.setLoccode, onlyPrivate, postSetLoccode); export default globalRouter; diff --git a/server/src/views/edit-profile.pug b/server/src/views/edit-profile.pug new file mode 100644 index 0000000000000000000000000000000000000000..9c3aff5406709ba28172eddf9aad67a9bdbb22a7 --- /dev/null +++ b/server/src/views/edit-profile.pug @@ -0,0 +1,6 @@ +block content + .signup-form_container + form(action = routes.base + routes.editProfile, method = "post") + input(type="text", name="nick_name", require=true, placeholder="Nick Name") + input(type="number", name="loc_code", require=true, placeholder="Local Code.") + input(type="submit", value="Submit") \ No newline at end of file diff --git a/server/src/views/home.pug b/server/src/views/home.pug index 62c12cd08b2d6174b0c91e80cb8e74451156aa8c..ab471299c1e388e1360dda63be71aa174af60145 100644 --- a/server/src/views/home.pug +++ b/server/src/views/home.pug @@ -7,4 +7,6 @@ block content li a(href=routes.base + routes.signup) 회원가입 li - a(href=routes.base + routes.login) 로그인 \ No newline at end of file + a(href=routes.base + routes.login) 로그인 + li + a(href=routes.base + routes.editProfile) 회원 정보 변경 \ No newline at end of file diff --git a/server/src/views/setLoccode.pug b/server/src/views/setLoccode.pug deleted file mode 100644 index 9ac8e41cd79494f7d67dd8e290aa4c9db70a86ef..0000000000000000000000000000000000000000 --- a/server/src/views/setLoccode.pug +++ /dev/null @@ -1,5 +0,0 @@ -block content - .signup-form_container - form(action = routes.base + routes.setLoccode, method = "post") - input(type="number", name="loccode", require=true, placeholder="Local Code.") - input(type="submit", value="Submit") \ No newline at end of file