Commit 358a25fe authored by KangMin An's avatar KangMin An
Browse files

Update: 지역코드 수정을 Profile 수정으로 통합

parent 98a89331
......@@ -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" });
};
......@@ -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;
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
......@@ -8,3 +8,5 @@ block content
a(href=routes.base + routes.signup) 회원가입
li
a(href=routes.base + routes.login) 로그인
li
a(href=routes.base + routes.editProfile) 회원 정보 변경
\ No newline at end of file
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
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