Browse Source

Fix no res.locals.user in api_v2

master
Menci 8 years ago
parent
commit
6cba999a52
  1. 3
      app.js

3
app.js

@ -61,6 +61,8 @@ global.syzoj = {
let multer = require('multer'); let multer = require('multer');
app.multer = multer({ dest: syzoj.utils.resolvePath(syzoj.config.upload_dir, 'tmp') }); app.multer = multer({ dest: syzoj.utils.resolvePath(syzoj.config.upload_dir, 'tmp') });
// This should before load api_v2, to init the `res.locals.user`
this.loadHooks();
// Trick to bypass CSRF for APIv2 // Trick to bypass CSRF for APIv2
app.use((() => { app.use((() => {
let router = new Express.Router(); let router = new Express.Router();
@ -73,7 +75,6 @@ global.syzoj = {
app.use(csurf({ cookie: true })); app.use(csurf({ cookie: true }));
await this.connectDatabase(); await this.connectDatabase();
this.loadHooks();
this.loadModules(); this.loadModules();
}, },
async connectDatabase() { async connectDatabase() {

Loading…
Cancel
Save