mirror of
https://github.com/flarum/core.git
synced 2025-07-30 21:20:24 +02:00
feat: Allow additional login params, Introduce LogInValidator
(#3670)
* Allow additional login params, dispatch 'LoggingIn' event * Update framework/core/js/src/forum/components/LogInModal.tsx Co-authored-by: David Wheatley <hi@davwheat.dev> * Introduce 'LogInValidator' * Apply fixes from StyleCI Co-authored-by: David Wheatley <hi@davwheat.dev> Co-authored-by: StyleCI Bot <bot@styleci.io>
This commit is contained in:
@@ -9,6 +9,7 @@ import ItemList from '../../common/utils/ItemList';
|
||||
import Stream from '../../common/utils/Stream';
|
||||
import type Mithril from 'mithril';
|
||||
import RequestError from '../../common/utils/RequestError';
|
||||
import type { LoginParams } from '../../common/Session';
|
||||
|
||||
export interface ILoginModalAttrs extends IInternalModalAttrs {
|
||||
identification?: string;
|
||||
@@ -172,13 +173,17 @@ export default class LogInModal<CustomAttrs extends ILoginModalAttrs = ILoginMod
|
||||
|
||||
this.loading = true;
|
||||
|
||||
const identification = this.identification();
|
||||
const password = this.password();
|
||||
const remember = this.remember();
|
||||
app.session.login(this.loginParams(), { errorHandler: this.onerror.bind(this) }).then(() => window.location.reload(), this.loaded.bind(this));
|
||||
}
|
||||
|
||||
app.session
|
||||
.login({ identification, password, remember }, { errorHandler: this.onerror.bind(this) })
|
||||
.then(() => window.location.reload(), this.loaded.bind(this));
|
||||
loginParams(): LoginParams {
|
||||
const data = {
|
||||
identification: this.identification(),
|
||||
password: this.password(),
|
||||
remember: this.remember(),
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
onerror(error: RequestError) {
|
||||
|
Reference in New Issue
Block a user