Browse Source

Disable problem creation when not logged in

master
Pisces000221 8 years ago
parent
commit
a0ade9138a
  1. 1
      modules/problem.js
  2. 12
      views/problems.ejs

1
modules/problem.js

@ -84,6 +84,7 @@ app.get('/problem/:id/edit', async (req, res) => {
let problem = await Problem.fromID(id); let problem = await Problem.fromID(id);
if (!problem) { if (!problem) {
if (!res.locals.user) throw 'Permission denied.';
problem = await Problem.create(); problem = await Problem.create();
problem.id = id; problem.id = id;
problem.allowedEdit = true; problem.allowedEdit = true;

12
views/problems.ejs

@ -1,13 +1,15 @@
<% this.title = '题库' %> <% this.title = '题库' %>
<% include header %> <% include header %>
<div class="padding"> <div class="padding">
<div class="ui grid"> <% if (user) { %>
<div class="row"> <div class="ui grid">
<div class="column"> <div class="row">
<a href="<%= syzoj.utils.makeUrl(['problem', 0, 'edit']) %>" class="ui mini right floated button">添加题目</a> <div class="column">
<a href="<%= syzoj.utils.makeUrl(['problem', 0, 'edit']) %>" class="ui mini right floated button">添加题目</a>
</div>
</div> </div>
</div> </div>
</div> <% } %>
<table class="ui very basic center aligned table"> <table class="ui very basic center aligned table">
<thead> <thead>
<tr> <tr>

Loading…
Cancel
Save