2013-11-12 09:27:12 +04:00
|
|
|
var admin = require('../controllers/admin'),
|
2013-12-10 08:41:58 +04:00
|
|
|
config = require('../config'),
|
2013-12-30 11:03:29 +04:00
|
|
|
middleware = require('../middleware').middleware;
|
2013-11-12 09:27:12 +04:00
|
|
|
|
|
|
|
module.exports = function (server) {
|
2014-01-05 10:40:53 +04:00
|
|
|
var subdir = config().paths.subdir;
|
2013-11-12 09:27:12 +04:00
|
|
|
// ### Admin routes
|
2013-11-26 13:38:54 +04:00
|
|
|
server.get('/logout/', function redirect(req, res) {
|
2013-11-12 09:27:12 +04:00
|
|
|
/*jslint unparam:true*/
|
2013-12-28 20:01:08 +04:00
|
|
|
res.redirect(301, subdir + '/ghost/signout/');
|
2013-11-26 13:38:54 +04:00
|
|
|
});
|
|
|
|
server.get('/signout/', function redirect(req, res) {
|
|
|
|
/*jslint unparam:true*/
|
2013-12-28 20:01:08 +04:00
|
|
|
res.redirect(301, subdir + '/ghost/signout/');
|
2013-11-26 13:38:54 +04:00
|
|
|
});
|
|
|
|
server.get('/signin/', function redirect(req, res) {
|
|
|
|
/*jslint unparam:true*/
|
2013-12-28 20:01:08 +04:00
|
|
|
res.redirect(301, subdir + '/ghost/signin/');
|
2013-11-26 13:38:54 +04:00
|
|
|
});
|
|
|
|
server.get('/signup/', function redirect(req, res) {
|
|
|
|
/*jslint unparam:true*/
|
2013-12-28 20:01:08 +04:00
|
|
|
res.redirect(301, subdir + '/ghost/signup/');
|
2013-11-12 09:27:12 +04:00
|
|
|
});
|
|
|
|
server.get('/ghost/login/', function redirect(req, res) {
|
|
|
|
/*jslint unparam:true*/
|
2013-12-28 20:01:08 +04:00
|
|
|
res.redirect(301, subdir + '/ghost/signin/');
|
2013-11-12 09:27:12 +04:00
|
|
|
});
|
2013-11-26 13:38:54 +04:00
|
|
|
|
|
|
|
server.get('/ghost/signout/', admin.logout);
|
2013-12-06 18:13:15 +04:00
|
|
|
server.get('/ghost/signin/', middleware.redirectToSignup, middleware.redirectToDashboard, admin.login);
|
2013-11-12 09:27:12 +04:00
|
|
|
server.get('/ghost/signup/', middleware.redirectToDashboard, admin.signup);
|
|
|
|
server.get('/ghost/forgotten/', middleware.redirectToDashboard, admin.forgotten);
|
2013-11-22 07:17:38 +04:00
|
|
|
server.post('/ghost/forgotten/', admin.generateResetToken);
|
|
|
|
server.get('/ghost/reset/:token', admin.reset);
|
|
|
|
server.post('/ghost/reset/:token', admin.resetPassword);
|
2013-11-12 09:27:12 +04:00
|
|
|
server.post('/ghost/signin/', admin.auth);
|
|
|
|
server.post('/ghost/signup/', admin.doRegister);
|
|
|
|
|
2014-02-14 14:00:11 +04:00
|
|
|
server.post('/ghost/changepw/', admin.changepw);
|
|
|
|
server.get('/ghost/editor(/:id)/', admin.editor);
|
|
|
|
server.get('/ghost/editor/', admin.editor);
|
|
|
|
server.get('/ghost/content/', admin.content);
|
|
|
|
server.get('/ghost/settings*', admin.settings);
|
|
|
|
server.get('/ghost/debug/', admin.debug.index);
|
|
|
|
|
|
|
|
server.post('/ghost/upload/', middleware.busboy, admin.uploader);
|
2013-11-12 09:27:12 +04:00
|
|
|
|
|
|
|
// redirect to /ghost and let that do the authentication to prevent redirects to /ghost//admin etc.
|
2013-11-17 22:40:26 +04:00
|
|
|
server.get(/\/((ghost-admin|admin|wp-admin|dashboard|signin)\/?)$/, function (req, res) {
|
2013-11-12 09:27:12 +04:00
|
|
|
/*jslint unparam:true*/
|
2013-12-28 20:01:08 +04:00
|
|
|
res.redirect(subdir + '/ghost/');
|
2013-11-12 09:27:12 +04:00
|
|
|
});
|
2014-02-20 02:56:06 +04:00
|
|
|
server.get(/\/ghost$/, function (req, res) {
|
2013-11-12 09:27:12 +04:00
|
|
|
/*jslint unparam:true*/
|
2013-12-28 20:01:08 +04:00
|
|
|
res.redirect(subdir + '/ghost/');
|
2013-11-12 09:27:12 +04:00
|
|
|
});
|
2014-02-14 14:00:11 +04:00
|
|
|
server.get('/ghost/', admin.index);
|
2013-11-12 09:27:12 +04:00
|
|
|
};
|