refreshless user logout
fixes #2842 - new Ember route for signout - new API route to allow async signout
This commit is contained in:
parent
7c75a34236
commit
74cd6e23fc
|
@ -10,6 +10,7 @@ Router.reopen({
|
|||
|
||||
Router.map(function () {
|
||||
this.route('signin');
|
||||
this.route('signout');
|
||||
this.route('signup');
|
||||
this.route('forgotten');
|
||||
this.route('reset', { path: '/reset/:token' });
|
||||
|
|
|
@ -0,0 +1,27 @@
|
|||
import ajax from 'ghost/utils/ajax';
|
||||
import styleBody from 'ghost/mixins/style-body';
|
||||
|
||||
var SignoutRoute = Ember.Route.extend(styleBody, {
|
||||
classNames: ['ghost-signout'],
|
||||
|
||||
beforeModel: function () {
|
||||
var self = this;
|
||||
|
||||
ajax({
|
||||
url: this.get('ghostPaths').adminUrl('signout'),
|
||||
type: 'POST',
|
||||
headers: {
|
||||
'X-CSRF-Token': this.get('csrf')
|
||||
}
|
||||
}).then(function () {
|
||||
|
||||
// @TODO: new CSRF token to enable logging back in w/o refreshing - see issue #2861 for details
|
||||
self.transitionTo('signin');
|
||||
}, function (resp) {
|
||||
self.notifications.showAPIError(resp, 'There was a problem logging out, please try again.');
|
||||
self.transitionTo('posts');
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
export default SignoutRoute;
|
|
@ -23,7 +23,7 @@
|
|||
<li class="divider"></li>
|
||||
<li class="usermenu-help"><a href="http://ghost.org/forum/">Help / Support</a></li>
|
||||
<li class="divider"></li>
|
||||
<li class="usermenu-signout"><a href="#">Sign Out</a></li>
|
||||
<li class="usermenu-signout">{{#link-to 'signout'}}Sign Out{{/link-to}}</li>
|
||||
{{/gh-popover}}
|
||||
</li>
|
||||
</ul>
|
||||
|
|
Loading…
Reference in New Issue