mirror of
https://github.com/flarum/framework.git
synced 2024-11-24 22:03:27 +08:00
parent
7a883b5563
commit
32648147e2
|
@ -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();
|
||||
|
|
|
@ -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());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue
Block a user