diff --git a/modules/user.js b/modules/user.js index 508bc94..5a30c43 100644 --- a/modules/user.js +++ b/modules/user.js @@ -87,6 +87,7 @@ app.get('/user/:id', async (req, res) => { try { let id = parseInt(req.params.id); let user = await User.fromID(id); + if (!user) throw new ErrorMessage('无此用户。'); user.ac_problems = await user.getACProblems(); user.articles = await user.getArticles(); user.allowedEdit = await user.isAllowedEditBy(res.locals.user); @@ -138,6 +139,7 @@ app.post('/user/:id/edit', async (req, res) => { try { let id = parseInt(req.params.id); user = await User.fromID(id); + if (!user) throw new ErrorMessage('无此用户。'); let allowedEdit = await user.isAllowedEditBy(res.locals.user); if (!allowedEdit) throw new ErrorMessage('您没有权限进行此操作。'); diff --git a/views/header.ejs b/views/header.ejs index 3fad227..f51502d 100644 --- a/views/header.ejs +++ b/views/header.ejs @@ -1,6 +1,6 @@ <% include util %> - +
diff --git a/views/problem.ejs b/views/problem.ejs index ef5a84b..50f8c08 100644 --- a/views/problem.ejs +++ b/views/problem.ejs @@ -242,6 +242,7 @@ if (contest) {