From 4bb0c85a8be8c6731f52bb897bf8dea636c0728a Mon Sep 17 00:00:00 2001 From: leehj050211 Date: Sun, 1 May 2022 19:53:26 +0900 Subject: [PATCH] =?UTF-8?q?Fix:=20=ED=86=A0=ED=81=B0=20=EC=9E=AC=EB=B0=9C?= =?UTF-8?q?=EA=B8=89=20=EB=B2=84=EA=B7=B8,=20=EC=9C=A0=EC=A0=80=20?= =?UTF-8?q?=EC=A0=95=EB=B3=B4=20=EB=B2=84=EA=B7=B8,=20=EA=B2=8C=EC=8B=9C?= =?UTF-8?q?=EA=B8=80=20=EB=B2=84=EA=B7=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package-lock.json | 4 ++-- package.json | 2 +- src/api/account/account.service.ts | 4 ++-- src/api/account/token.repository.ts | 4 ++-- src/api/board/post.service.ts | 8 +++++++- src/api/board/repository/post.repository.ts | 4 ++-- 6 files changed, 16 insertions(+), 10 deletions(-) diff --git a/package-lock.json b/package-lock.json index 7ad45ca..6fa0896 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "BSM", - "version": "1.4.0", + "version": "1.4.1", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "BSM", - "version": "1.4.0", + "version": "1.4.1", "dependencies": { "@types/express": "^4.17.13", "@types/jsonwebtoken": "^8.5.6", diff --git a/package.json b/package.json index ad45fcc..3607618 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "BSM", - "version": "1.4.0", + "version": "1.4.1", "dependencies": { "@types/express": "^4.17.13", "@types/jsonwebtoken": "^8.5.6", diff --git a/src/api/account/account.service.ts b/src/api/account/account.service.ts index 9a42219..56fbd22 100644 --- a/src/api/account/account.service.ts +++ b/src/api/account/account.service.ts @@ -76,7 +76,7 @@ const viewUser = async ( viewUser.userType = "none"; } return { - user + user: viewUser }; } viewUser.userType = "active"; @@ -94,7 +94,7 @@ const viewUser = async ( viewUser.permission = false; } return { - user + user: viewUser }; } diff --git a/src/api/account/token.repository.ts b/src/api/account/token.repository.ts index 27ef34b..2cb57c4 100644 --- a/src/api/account/token.repository.ts +++ b/src/api/account/token.repository.ts @@ -4,9 +4,9 @@ const pool = require('../../util/db'); const getToken = async ( token: string, ): Promise<{usercode: number, created: string} | null> => { - const getQuery="SELECT user_code usercode, created FROM tokens WHERE token = ? AND valid = 1"; + const getQuery="SELECT usercode, created FROM tokens WHERE token = ? AND valid = 1"; // SELECT - // user_code usercode, + // usercode, // created // FROM tokens // WHERE diff --git a/src/api/board/post.service.ts b/src/api/board/post.service.ts index b8ed494..eaaaad8 100644 --- a/src/api/board/post.service.ts +++ b/src/api/board/post.service.ts @@ -1,4 +1,4 @@ -import { NotFoundException, UnAuthorizedException, ForbiddenException } from '../../util/exceptions'; +import { NotFoundException, UnAuthorizedException, ForbiddenException, BadRequestException } from '../../util/exceptions'; import { User } from '../account/User'; import * as boardRepository from './repository/board.repository'; import * as postRepository from './repository/post.repository'; @@ -120,6 +120,9 @@ const writePost = async ( if (boardTypeList[boardType].level > user.getUser().level) { throw new ForbiddenException(); } + if (!title || !content) { + throw new BadRequestException(); + } await postRepository.insertPost(boardType, user.getUser().code, title, xss.process(content)); if (boardType == 'notice') { @@ -149,6 +152,9 @@ const updatePost = async ( if (!(postUsercode == user.getUser().code || user.getUser().level >= 3)) { throw new ForbiddenException(); } + if (!title || !content) { + throw new BadRequestException(); + } await postRepository.updatePost(boardType, postNo, title, xss.process(content)); } diff --git a/src/api/board/repository/post.repository.ts b/src/api/board/repository/post.repository.ts index 09796c2..4d6bb46 100644 --- a/src/api/board/repository/post.repository.ts +++ b/src/api/board/repository/post.repository.ts @@ -77,11 +77,11 @@ const insertPost = async ( title :string, content: string ) => { - const insertQuery="INSERT INTO post (board,post_no, user_code, title, content, date) SELECT ?, COUNT(post_no)+1, ?, ?, ?, now() FROM post WHERE board = ?"; + const insertQuery="INSERT INTO post (board,post_no, usercode, title, content, date) SELECT ?, COUNT(post_no)+1, ?, ?, ?, now() FROM post WHERE board = ?"; // INSERT INTO post ( // board, // post_no, - // user_code, + // usercode, // title, // content, // date)