diff --git a/js/forum/src/components/DiscussionPage.js b/js/forum/src/components/DiscussionPage.js index ac2294eeb..bcfb15c47 100644 --- a/js/forum/src/components/DiscussionPage.js +++ b/js/forum/src/components/DiscussionPage.js @@ -55,8 +55,6 @@ export default class DiscussionPage extends mixin(Component, evented) { app.current = this; app.drawer.hide(); app.modal.close(); - - app.session.on('loggedIn', this.loggedInHandler = this.refresh.bind(this)); } onunload(e) { @@ -81,7 +79,6 @@ export default class DiscussionPage extends mixin(Component, evented) { // discussion, minimize the composer – unless it's empty, in which case // we'll just close it. app.pane.disable(); - app.session.off('loggedIn', this.loggedInHandler); if (app.composingReplyTo(this.discussion) && !app.composer.component.content()) { app.composer.hide(); diff --git a/js/lib/Session.js b/js/lib/Session.js index 3d67b1a91..3feaf21f4 100644 --- a/js/lib/Session.js +++ b/js/lib/Session.js @@ -1,13 +1,8 @@ -import mixin from 'flarum/utils/mixin'; -import evented from 'flarum/utils/evented'; - /** * The `Session` class defines the current user session. It stores a reference * to the current authenticated user, and provides methods to log in/out. - * - * @extends evented */ -export default class Session extends mixin(class {}, evented) { +export default class Session { constructor(token, user) { super(); @@ -35,31 +30,12 @@ export default class Session extends mixin(class {}, evented) { * @return {Promise} */ login(identification, password) { - const deferred = m.deferred(); - - app.request({ + return app.request({ method: 'POST', url: app.forum.attribute('baseUrl') + '/login', data: {identification, password} - }).then( - // FIXME: reload the page on success. Somehow serialize what the user's - // intention was, and then perform that intention after the page reloads. - response => { - this.token = response.token; - - app.store.find('users', response.userId).then(user => { - this.user = user; - this.trigger('loggedIn', user); - deferred.resolve(user); - }); - }, - - response => { - deferred.reject(response); - } - ); - - return deferred.promise; + }) + .then(() => window.location.reload()); } /**