refreshless user logout

fixes #2842
- new Ember route for signout
- new API route to allow async signout
This commit is contained in:
Maurice Williams 2014-06-01 15:30:50 -04:00
parent 7c75a34236
commit 74cd6e23fc
3 changed files with 29 additions and 1 deletions

View File

@ -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' });

27
routes/signout.js Normal file
View File

@ -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;

View File

@ -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>