Skip to content
This repository has been archived by the owner on Oct 31, 2022. It is now read-only.

Commit

Permalink
Fix: 토큰 재발급 버그, 유저 정보 버그, 게시글 버그
Browse files Browse the repository at this point in the history
  • Loading branch information
leehj050211 committed May 1, 2022
1 parent 943b112 commit 4bb0c85
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 10 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
4 changes: 2 additions & 2 deletions src/api/account/account.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ const viewUser = async (
viewUser.userType = "none";
}
return {
user
user: viewUser
};
}
viewUser.userType = "active";
Expand All @@ -94,7 +94,7 @@ const viewUser = async (
viewUser.permission = false;
}
return {
user
user: viewUser
};
}

Expand Down
4 changes: 2 additions & 2 deletions src/api/account/token.repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 7 additions & 1 deletion src/api/board/post.service.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -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') {
Expand Down Expand Up @@ -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));
}
Expand Down
4 changes: 2 additions & 2 deletions src/api/board/repository/post.repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 4bb0c85

Please sign in to comment.