mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-11-30 21:40:39 +03:00
Rename /logout/ to /signout/ and /login/ to /signin/
Closes #443 - Renamed routes - Added redirects for old routes - Added unit test for redirect - Updated references to old routes in templates, html
This commit is contained in:
parent
3209a96029
commit
d7521958d5
@ -14,7 +14,7 @@
|
|||||||
'debug/' : 'debug',
|
'debug/' : 'debug',
|
||||||
'register/' : 'register',
|
'register/' : 'register',
|
||||||
'signup/' : 'signup',
|
'signup/' : 'signup',
|
||||||
'login/' : 'login'
|
'signin/' : 'login'
|
||||||
},
|
},
|
||||||
|
|
||||||
signup: function () {
|
signup: function () {
|
||||||
|
@ -56,7 +56,7 @@
|
|||||||
self = this;
|
self = this;
|
||||||
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: '/ghost/login/',
|
url: '/ghost/signin/',
|
||||||
type: 'POST',
|
type: 'POST',
|
||||||
data: {
|
data: {
|
||||||
email: email,
|
email: email,
|
||||||
|
@ -159,7 +159,7 @@ adminControllers = {
|
|||||||
delete req.session.user;
|
delete req.session.user;
|
||||||
var msg = {
|
var msg = {
|
||||||
type: 'success',
|
type: 'success',
|
||||||
message: 'You were successfully logged out',
|
message: 'You were successfully signed out',
|
||||||
status: 'passive',
|
status: 'passive',
|
||||||
id: 'successlogout'
|
id: 'successlogout'
|
||||||
};
|
};
|
||||||
@ -168,7 +168,7 @@ adminControllers = {
|
|||||||
ghost.notifications.push(msg);
|
ghost.notifications.push(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
res.redirect('/ghost/login/');
|
res.redirect('/ghost/signin/');
|
||||||
},
|
},
|
||||||
'index': function (req, res) {
|
'index': function (req, res) {
|
||||||
res.render('dashboard', {
|
res.render('dashboard', {
|
||||||
@ -310,7 +310,7 @@ adminControllers = {
|
|||||||
|
|
||||||
return api.notifications.add(notification).then(function () {
|
return api.notifications.add(notification).then(function () {
|
||||||
delete req.session.user;
|
delete req.session.user;
|
||||||
res.redirect('/ghost/login/');
|
res.redirect('/ghost/signin/');
|
||||||
});
|
});
|
||||||
|
|
||||||
}, function importFailure(error) {
|
}, function importFailure(error) {
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
<li class="usermenu-help"><a href="#">Help / Support</a></li>
|
<li class="usermenu-help"><a href="#">Help / Support</a></li>
|
||||||
<li class="usermenu-shortcuts"><a href="#">Keyboard Shortcuts</a></li>
|
<li class="usermenu-shortcuts"><a href="#">Keyboard Shortcuts</a></li>
|
||||||
<li class="divider"></li>
|
<li class="divider"></li>
|
||||||
<li class="usermenu-signout"><a href="/logout/">Sign Out</a></li>
|
<li class="usermenu-signout"><a href="/signout/">Sign Out</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
@ -5,7 +5,7 @@ casper.test.begin("Ghost admin will load login page", 2, function suite(test) {
|
|||||||
|
|
||||||
casper.start(url + "ghost", function testTitleAndUrl() {
|
casper.start(url + "ghost", function testTitleAndUrl() {
|
||||||
test.assertTitle("", "Ghost admin has no title");
|
test.assertTitle("", "Ghost admin has no title");
|
||||||
test.assertEquals(this.getCurrentUrl(), url + "ghost/login/", "Ghost requires login");
|
test.assertEquals(this.getCurrentUrl(), url + "ghost/signin/", "Ghost requires login");
|
||||||
}).viewport(1280, 1024);
|
}).viewport(1280, 1024);
|
||||||
|
|
||||||
casper.run(function () {
|
casper.run(function () {
|
||||||
@ -13,12 +13,24 @@ casper.test.begin("Ghost admin will load login page", 2, function suite(test) {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
casper.test.begin('Redirects to signin', 2, function suite(test) {
|
||||||
|
casper.test.filename = 'login_redirect_test.png';
|
||||||
|
|
||||||
|
casper.start(url + 'ghost/login/', function testRedirect(response) {
|
||||||
|
test.assertEqual(response.status, 200, 'Response status should be 200.');
|
||||||
|
test.assert(/\/signin\/$/.test(response.url), 'Should be redirected to /signin/. Actual response url: ' + response.url + '.');
|
||||||
|
});
|
||||||
|
|
||||||
|
casper.run(function () {
|
||||||
|
test.done();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
casper.test.begin("Can login to Ghost", 3, function suite(test) {
|
casper.test.begin("Can login to Ghost", 3, function suite(test) {
|
||||||
|
|
||||||
casper.test.filename = "login_test.png";
|
casper.test.filename = "login_test.png";
|
||||||
|
|
||||||
casper.start(url + "ghost/login/", function testTitle() {
|
casper.start(url + "ghost/signin/", function testTitle() {
|
||||||
test.assertTitle("", "Ghost admin has no title");
|
test.assertTitle("", "Ghost admin has no title");
|
||||||
}).viewport(1280, 1024);
|
}).viewport(1280, 1024);
|
||||||
|
|
||||||
@ -50,7 +62,7 @@ casper.test.begin("Can't spam it", 2, function suite(test) {
|
|||||||
|
|
||||||
casper.test.filename = "login_test.png";
|
casper.test.filename = "login_test.png";
|
||||||
|
|
||||||
casper.start(url + "ghost/login/", function testTitle() {
|
casper.start(url + "ghost/signin/", function testTitle() {
|
||||||
test.assertTitle("", "Ghost admin has no title");
|
test.assertTitle("", "Ghost admin has no title");
|
||||||
}).viewport(1280, 1024);
|
}).viewport(1280, 1024);
|
||||||
|
|
||||||
|
@ -52,7 +52,7 @@
|
|||||||
<li class="usermenu-help"><a href="#">Help / Support</a></li>
|
<li class="usermenu-help"><a href="#">Help / Support</a></li>
|
||||||
<li class="usermenu-shortcuts"><a href="#">Keyboard Shortcuts</a></li>
|
<li class="usermenu-shortcuts"><a href="#">Keyboard Shortcuts</a></li>
|
||||||
<li class="divider"></li>
|
<li class="divider"></li>
|
||||||
<li class="usermenu-signout"><a href="/logout/">Sign Out</a></li>
|
<li class="usermenu-signout"><a href="/signout/">Sign Out</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
@ -45,7 +45,7 @@
|
|||||||
<li class="usermenu-help"><a href="#">Help / Support</a></li>
|
<li class="usermenu-help"><a href="#">Help / Support</a></li>
|
||||||
<li class="usermenu-shortcuts"><a href="#">Keyboard Shortcuts</a></li>
|
<li class="usermenu-shortcuts"><a href="#">Keyboard Shortcuts</a></li>
|
||||||
<li class="divider"></li>
|
<li class="divider"></li>
|
||||||
<li class="usermenu-signout"><a href="/logout/">Sign Out</a></li>
|
<li class="usermenu-signout"><a href="/signout/">Sign Out</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
20
index.js
20
index.js
@ -44,7 +44,7 @@ function auth(req, res, next) {
|
|||||||
if (path !== '') {
|
if (path !== '') {
|
||||||
msg = {
|
msg = {
|
||||||
type: 'error',
|
type: 'error',
|
||||||
message: 'Please Log In',
|
message: 'Please Sign In',
|
||||||
status: 'passive',
|
status: 'passive',
|
||||||
id: 'failedauth'
|
id: 'failedauth'
|
||||||
};
|
};
|
||||||
@ -54,7 +54,7 @@ function auth(req, res, next) {
|
|||||||
}
|
}
|
||||||
redirect = '?r=' + encodeURIComponent(path);
|
redirect = '?r=' + encodeURIComponent(path);
|
||||||
}
|
}
|
||||||
return res.redirect('/ghost/login/' + redirect);
|
return res.redirect('/ghost/signin/' + redirect);
|
||||||
}
|
}
|
||||||
|
|
||||||
next();
|
next();
|
||||||
@ -114,7 +114,7 @@ function signupValidate(req, res, next) {
|
|||||||
function authAPI(req, res, next) {
|
function authAPI(req, res, next) {
|
||||||
if (!req.session.user) {
|
if (!req.session.user) {
|
||||||
// TODO: standardize error format/codes/messages
|
// TODO: standardize error format/codes/messages
|
||||||
var err = { code: 42, message: 'Please login' };
|
var err = { code: 42, message: 'Please sign in' };
|
||||||
res.json(401, { error: err });
|
res.json(401, { error: err });
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -247,10 +247,16 @@ when.all([ghost.init(), filters.loadCoreFilters(ghost), helpers.loadCoreHelpers(
|
|||||||
|
|
||||||
// ### Admin routes
|
// ### Admin routes
|
||||||
/* TODO: put these somewhere in admin */
|
/* TODO: put these somewhere in admin */
|
||||||
ghost.app().get(/^\/logout\/?$/, admin.logout);
|
ghost.app().get(/^\/logout\/?$/, function redirect(req, res) {
|
||||||
ghost.app().get('/ghost/login/', redirectToDashboard, admin.login);
|
res.redirect(301, '/signout/');
|
||||||
|
});
|
||||||
|
ghost.app().get(/^\/signout\/?$/, admin.logout);
|
||||||
|
ghost.app().get('/ghost/login/', function redirect(req, res) {
|
||||||
|
res.redirect(301, '/ghost/signin/');
|
||||||
|
});
|
||||||
|
ghost.app().get('/ghost/signin/', redirectToDashboard, admin.login);
|
||||||
ghost.app().get('/ghost/signup/', redirectToDashboard, admin.signup);
|
ghost.app().get('/ghost/signup/', redirectToDashboard, admin.signup);
|
||||||
ghost.app().post('/ghost/login/', admin.auth);
|
ghost.app().post('/ghost/signin/', admin.auth);
|
||||||
ghost.app().post('/ghost/signup/', signupValidate, admin.doRegister);
|
ghost.app().post('/ghost/signup/', signupValidate, admin.doRegister);
|
||||||
ghost.app().post('/ghost/changepw/', auth, admin.changepw);
|
ghost.app().post('/ghost/changepw/', auth, admin.changepw);
|
||||||
ghost.app().get('/ghost/editor/:id', auth, admin.editor);
|
ghost.app().get('/ghost/editor/:id', auth, admin.editor);
|
||||||
@ -262,7 +268,7 @@ when.all([ghost.init(), filters.loadCoreFilters(ghost), helpers.loadCoreHelpers(
|
|||||||
ghost.app().post('/ghost/debug/db/import/', auth, admin.debug['import']);
|
ghost.app().post('/ghost/debug/db/import/', auth, admin.debug['import']);
|
||||||
ghost.app().get('/ghost/debug/db/reset/', auth, admin.debug.reset);
|
ghost.app().get('/ghost/debug/db/reset/', auth, admin.debug.reset);
|
||||||
ghost.app().post('/ghost/upload', admin.uploader);
|
ghost.app().post('/ghost/upload', admin.uploader);
|
||||||
ghost.app().get(/^\/(ghost$|(ghost-admin|admin|wp-admin|dashboard|login)\/?)/, auth, function (req, res) {
|
ghost.app().get(/^\/(ghost$|(ghost-admin|admin|wp-admin|dashboard|signin)\/?)/, auth, function (req, res) {
|
||||||
res.redirect('/ghost/');
|
res.redirect('/ghost/');
|
||||||
});
|
});
|
||||||
ghost.app().get('/ghost/', auth, admin.index);
|
ghost.app().get('/ghost/', auth, admin.index);
|
||||||
|
Loading…
Reference in New Issue
Block a user