allow re-login when authorization fails on editor.edit route

This commit is contained in:
Marco Otte-Witte 2014-07-31 21:15:55 +02:00 committed by Jason Williams
parent 7946926c93
commit 569c185de7
6 changed files with 37 additions and 20 deletions

View File

@ -0,0 +1,12 @@
import SigninController from '../signin';
export default SigninController.extend({
actions: {
authenticate: function (data) {
var self = this;
this._super(data).then(function () {
self.send('closeModal');
});
}
}
});

View File

@ -27,9 +27,9 @@ AuthenticationInitializer = {
}; };
SimpleAuth.Session.reopen({ SimpleAuth.Session.reopen({
user: Ember.computed(function () { user: function () {
return container.lookup('store:main').find('user', 'me'); return container.lookup('store:main').find('user', 'me');
}) }).property()
}); });
SimpleAuth.Authenticators.OAuth2.reopen({ SimpleAuth.Authenticators.OAuth2.reopen({

View File

@ -23,22 +23,6 @@ ApplicationRoute = Ember.Route.extend(SimpleAuth.ApplicationRouteMixin, Shortcut
}, },
actions: { actions: {
authorizationFailed: function () {
var currentRoute = this.get('controller').get('currentRouteName'),
editorController;
if (currentRoute.split('.')[0] === 'editor') {
editorController = this.controllerFor(currentRoute);
if (editorController.get('isDirty')) {
this.send('openModal', 'auth-failed-unsaved', editorController);
return;
}
}
this._super();
},
toggleGlobalMobileNav: function () { toggleGlobalMobileNav: function () {
this.toggleProperty('controller.showGlobalMobileNav'); this.toggleProperty('controller.showGlobalMobileNav');
}, },
@ -46,9 +30,11 @@ ApplicationRoute = Ember.Route.extend(SimpleAuth.ApplicationRouteMixin, Shortcut
openSettingsMenu: function () { openSettingsMenu: function () {
this.set('controller.showSettingsMenu', true); this.set('controller.showSettingsMenu', true);
}, },
closeSettingsMenu: function () { closeSettingsMenu: function () {
this.set('controller.showSettingsMenu', false); this.set('controller.showSettingsMenu', false);
}, },
toggleSettingsMenu: function () { toggleSettingsMenu: function () {
this.toggleProperty('controller.showSettingsMenu'); this.toggleProperty('controller.showSettingsMenu');
}, },

View File

@ -48,6 +48,12 @@ var EditorEditRoute = AuthenticatedRoute.extend(base, {
return self.replaceWith('posts.index'); return self.replaceWith('posts.index');
} }
}); });
},
actions: {
authorizationFailed: function () {
this.send('openModal', 'signin');
}
} }
}); });

View File

@ -0,0 +1,14 @@
{{#gh-modal-dialog action="closeModal" showClose=true type="action" style="wide,centered" animation="fade"
title="Please login again" confirm=confirm}}
<form id="login" class="login-form" method="post" novalidate="novalidate" {{action 'validateAndAuthenticate' on='submit'}}>
<div class="email-wrap">
{{input class="email" type="email" placeholder="Email Address" name="identification" autofocus="autofocus" autocapitalize="off" autocorrect="off" value=identification}}
</div>
<div class="password-wrap">
{{input class="password" type="password" placeholder="Password" name="password" value=password}}
</div>
<button class="button-save" type="submit" {{action "validateAndAuthenticate"}} {{bind-attr disabled=submitting}}>Log in</button>
</form>
{{/gh-modal-dialog}}

View File

@ -2,8 +2,7 @@
<form id="login" class="login-form" method="post" novalidate="novalidate" {{action 'validateAndAuthenticate' on='submit'}}> <form id="login" class="login-form" method="post" novalidate="novalidate" {{action 'validateAndAuthenticate' on='submit'}}>
<div class="email-wrap"> <div class="email-wrap">
<span class="input-icon icon-mail"> <span class="input-icon icon-mail">
{{gh-trim-focus-input class="email" type="email" placeholder="Email Address" name="identification" {{gh-trim-focus-input class="email" type="email" placeholder="Email Address" name="identification" autocapitalize="off" autocorrect="off" value=identification}}
autocapitalize="off" autocorrect="off" value=identification}}
</span> </span>
</div> </div>
<div class="password-wrap"> <div class="password-wrap">