This repository has been archived by the owner on Oct 31, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
cd7375b
commit 678910d
Showing
9 changed files
with
185 additions
and
257 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import { InternalServerException } from '../../util/exceptions'; | ||
const pool = require('../../util/db'); | ||
|
||
const getToken = async ( | ||
token: string, | ||
) => { | ||
const getTokenQuery="SELECT * FROM `tokens` WHERE `token`=? AND `valid`=1"; | ||
try{ | ||
const [rows] = await pool.query(getTokenQuery, [token]); | ||
if(rows.length) | ||
return rows[0]; | ||
else | ||
return null; | ||
}catch(err){ | ||
console.error(err); | ||
throw new InternalServerException(); | ||
} | ||
} | ||
|
||
const insertToken = async ( | ||
token: string, | ||
memberCode: number | ||
) => { | ||
const insertTokenQuery="INSERT INTO `tokens` VALUES(?, 1, ?, now())"; | ||
try{ | ||
await pool.query(insertTokenQuery, [token, memberCode]); | ||
}catch(err){ | ||
console.error(err); | ||
throw new InternalServerException(); | ||
} | ||
} | ||
|
||
export { | ||
getToken, | ||
insertToken | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,18 @@ | ||
const express = require('express'); | ||
const router = express.Router(); | ||
const jwt = require('./util/jwt'); | ||
|
||
const apiRouter = require('./api/api.controller'); | ||
const viewRouter = require('./view/view.controller'); | ||
|
||
// 업데이트 확인 url 하위호환 | ||
const versionController = require('./api/version/version.controller'); | ||
router.post('/database', versionController.getVersionLegacy);// 업데이트 확인 url 하위호환 | ||
|
||
router.post('/database', versionController.getVersionLegacy); | ||
|
||
router.use('/api', apiRouter); | ||
router.use('/', viewRouter); | ||
|
||
|
||
router.use((req, res) => { | ||
const jwtValue = jwt.check(req.cookies.token); | ||
res.status(404).render('404', { | ||
member:{ | ||
isLogin:jwtValue.isLogin, | ||
code:jwtValue.memberCode, | ||
id:jwtValue.memberId, | ||
nickname:jwtValue.memberNickname, | ||
level:jwtValue.memberLevel, | ||
grade:jwtValue.grade, | ||
classNo:jwtValue.classNo, | ||
studentNo:jwtValue.studentNo, | ||
} | ||
}) | ||
res.status(404).render('404'); | ||
}) | ||
|
||
module.exports = router; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.