Fixes user authentication when registering via the module API (#10257)
* Fixes authentication when user is registered via module API * Remove "on_logging_in" action --------- Signed-off-by: Mikhail Aheichyk <mikhail.aheichyk@nordeck.net> Co-authored-by: Mikhail Aheichyk <mikhail.aheichyk@nordeck.net>
This commit is contained in:
parent
af1ec76149
commit
3e340d5906
3 changed files with 45 additions and 10 deletions
|
@ -36,6 +36,7 @@ import { MatrixClientPeg } from "../MatrixClientPeg";
|
|||
import { getCachedRoomIDForAlias } from "../RoomAliasCache";
|
||||
import { Action } from "../dispatcher/actions";
|
||||
import { OverwriteLoginPayload } from "../dispatcher/payloads/OverwriteLoginPayload";
|
||||
import { ActionPayload } from "../dispatcher/payloads";
|
||||
|
||||
/**
|
||||
* Glue between the `ModuleApi` interface and the react-sdk. Anticipates one instance
|
||||
|
@ -44,6 +45,18 @@ import { OverwriteLoginPayload } from "../dispatcher/payloads/OverwriteLoginPayl
|
|||
export class ProxiedModuleApi implements ModuleApi {
|
||||
private cachedTranslations: Optional<TranslationStringsObject>;
|
||||
|
||||
private overrideLoginResolve?: () => void;
|
||||
|
||||
public constructor() {
|
||||
dispatcher.register(this.onAction);
|
||||
}
|
||||
|
||||
private onAction = (payload: ActionPayload): void => {
|
||||
if (payload.action === Action.OnLoggedIn) {
|
||||
this.overrideLoginResolve?.();
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* All custom translations used by the associated module.
|
||||
*/
|
||||
|
@ -155,6 +168,11 @@ export class ProxiedModuleApi implements ModuleApi {
|
|||
},
|
||||
true,
|
||||
); // require to be sync to match inherited interface behaviour
|
||||
|
||||
// wait for login to complete
|
||||
await new Promise<void>((resolve) => {
|
||||
this.overrideLoginResolve = resolve;
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue