mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-25 11:55:03 +03:00
Redirect signin if authenticated
closes #3147 - added beforeModel redirect - added test
This commit is contained in:
parent
9214f25dee
commit
ace2cc1673
@ -3,6 +3,11 @@ import loadingIndicator from 'ghost/mixins/loading-indicator';
|
||||
|
||||
var SigninRoute = Ember.Route.extend(styleBody, loadingIndicator, {
|
||||
classNames: ['ghost-login'],
|
||||
beforeModel: function () {
|
||||
if (this.get('session').isAuthenticated) {
|
||||
this.transitionTo(Ember.SimpleAuth.routeAfterAuthentication);
|
||||
}
|
||||
},
|
||||
actions: {
|
||||
sessionAuthenticationFailed: function (error) {
|
||||
this.notifications.showError(error.message);
|
||||
|
@ -87,6 +87,11 @@ screens = {
|
||||
url: 'ghost/signin/',
|
||||
selector: '.button-save'
|
||||
},
|
||||
'signin-authenticated': {
|
||||
url: 'ghost/signin/',
|
||||
//signin with authenticated user redirects to posts
|
||||
selector: '#main-menu .content.active'
|
||||
},
|
||||
'signout': {
|
||||
url: 'ghost/signout/',
|
||||
linkSelector: '#user-menu li.usermenu-signout a',
|
||||
|
@ -146,6 +146,35 @@ CasperTest.begin('Can login to Ghost', 5, function suite(test) {
|
||||
});
|
||||
}, true);
|
||||
|
||||
CasperTest.begin('Authenticated user is redirected', 8, function suite(test) {
|
||||
casper.thenOpenAndWaitForPageLoad('signin', function testTitleAndUrl() {
|
||||
test.assertTitle('Ghost Admin', 'Ghost admin has no title');
|
||||
test.assertUrlMatch(/ghost\/signin\/$/, 'Landed on the correct URL');
|
||||
});
|
||||
|
||||
casper.waitForOpaque('.login-box', function then() {
|
||||
this.fillAndSave('#login', user);
|
||||
});
|
||||
|
||||
casper.wait(2000);
|
||||
|
||||
casper.waitForResource(/posts/, function testForDashboard() {
|
||||
test.assertUrlMatch(/ghost\/\d+\/$/, 'Landed on the correct URL');
|
||||
test.assertExists('#global-header', 'Global admin header is present');
|
||||
test.assertExists('.manage', 'We\'re now on content');
|
||||
}, function onTimeOut() {
|
||||
test.fail('Failed to signin');
|
||||
});
|
||||
|
||||
casper.thenOpenAndWaitForPageLoad('signin-authenticated', function testTitleAndUrl() {
|
||||
test.assertUrlMatch(/ghost\/\d+\/$/, 'Landed on the correct URL');
|
||||
test.assertExists('#global-header', 'Global admin header is present');
|
||||
test.assertExists('.manage', 'We\'re now on content');
|
||||
}, function onTimeOut() {
|
||||
test.fail('Failed to redirect');
|
||||
});
|
||||
}, true);
|
||||
|
||||
// TODO: please uncomment when the validation problem is fixed (https://github.com/TryGhost/Ghost/issues/3120)
|
||||
// CasperTest.begin('Ensure email field form validation', 3, function suite(test) {
|
||||
// casper.thenOpenAndWaitForPageLoad('signin', function testTitleAndUrl() {
|
||||
|
Loading…
Reference in New Issue
Block a user