mirror of
https://github.com/flarum/framework.git
synced 2024-11-25 00:23:13 +08:00
parent
7a883b5563
commit
32648147e2
|
@ -55,8 +55,6 @@ export default class DiscussionPage extends mixin(Component, evented) {
|
||||||
app.current = this;
|
app.current = this;
|
||||||
app.drawer.hide();
|
app.drawer.hide();
|
||||||
app.modal.close();
|
app.modal.close();
|
||||||
|
|
||||||
app.session.on('loggedIn', this.loggedInHandler = this.refresh.bind(this));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
onunload(e) {
|
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
|
// discussion, minimize the composer – unless it's empty, in which case
|
||||||
// we'll just close it.
|
// we'll just close it.
|
||||||
app.pane.disable();
|
app.pane.disable();
|
||||||
app.session.off('loggedIn', this.loggedInHandler);
|
|
||||||
|
|
||||||
if (app.composingReplyTo(this.discussion) && !app.composer.component.content()) {
|
if (app.composingReplyTo(this.discussion) && !app.composer.component.content()) {
|
||||||
app.composer.hide();
|
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
|
* The `Session` class defines the current user session. It stores a reference
|
||||||
* to the current authenticated user, and provides methods to log in/out.
|
* 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) {
|
constructor(token, user) {
|
||||||
super();
|
super();
|
||||||
|
|
||||||
|
@ -35,31 +30,12 @@ export default class Session extends mixin(class {}, evented) {
|
||||||
* @return {Promise}
|
* @return {Promise}
|
||||||
*/
|
*/
|
||||||
login(identification, password) {
|
login(identification, password) {
|
||||||
const deferred = m.deferred();
|
return app.request({
|
||||||
|
|
||||||
app.request({
|
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
url: app.forum.attribute('baseUrl') + '/login',
|
url: app.forum.attribute('baseUrl') + '/login',
|
||||||
data: {identification, password}
|
data: {identification, password}
|
||||||
}).then(
|
})
|
||||||
// FIXME: reload the page on success. Somehow serialize what the user's
|
.then(() => window.location.reload());
|
||||||
// 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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue
Block a user