From 9e8e1fa37d3c51c4b7468d796f4c45e1a4890a0a Mon Sep 17 00:00:00 2001 From: Hannah Wolfe Date: Tue, 3 Jun 2014 19:20:30 +0100 Subject: [PATCH] Ember redirect to signup closes #2779 - adds temporary code to redirect the ember admin to signup if a user doesn't exist. - done serverside as this makes most sense? --- core/server/middleware/index.js | 9 +++++++++ core/server/routes/admin.js | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/core/server/middleware/index.js b/core/server/middleware/index.js index ada3465597..f1e807d1af 100644 --- a/core/server/middleware/index.js +++ b/core/server/middleware/index.js @@ -180,6 +180,15 @@ function redirectToSignup(req, res, next) { api.users.doesUserExist().then(function (exists) { if (!exists) { + // TODO remove this when ember admin becomes the default + if (req.path.match(/\/ember\//)) { + if (!req.path.match(/\/ghost\/ember\/signup\//)) { + return res.redirect(config().paths.subdir + '/ghost/ember/signup/'); + } else { + return next(); + } + } + // END remove this return res.redirect(config().paths.subdir + '/ghost/signup/'); } next(); diff --git a/core/server/routes/admin.js b/core/server/routes/admin.js index d1a9a00fc3..5e79c6ee60 100644 --- a/core/server/routes/admin.js +++ b/core/server/routes/admin.js @@ -10,7 +10,7 @@ var admin = require('../controllers/admin'), adminRoutes = function (server) { // Have ember route look for hits first // to prevent conflicts with pre-existing routes - server.get('/ghost/ember/*', admin.index); + server.get('/ghost/ember/*', middleware.redirectToSignup, admin.index); var subdir = config().paths.subdir; // ### Admin routes