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
|
@ -15,12 +15,15 @@ limitations under the License.
|
|||
*/
|
||||
|
||||
import { TranslationStringsObject } from "@matrix-org/react-sdk-module-api/lib/types/translations";
|
||||
import { AccountAuthInfo } from "@matrix-org/react-sdk-module-api/lib/types/AccountAuthInfo";
|
||||
|
||||
import { ProxiedModuleApi } from "../../src/modules/ProxiedModuleApi";
|
||||
import { stubClient } from "../test-utils";
|
||||
import { setLanguage } from "../../src/languageHandler";
|
||||
import { ModuleRunner } from "../../src/modules/ModuleRunner";
|
||||
import { registerMockModule } from "./MockModule";
|
||||
import defaultDispatcher from "../../src/dispatcher/dispatcher";
|
||||
import { Action } from "../../src/dispatcher/actions";
|
||||
|
||||
describe("ProxiedApiModule", () => {
|
||||
afterEach(() => {
|
||||
|
@ -44,6 +47,29 @@ describe("ProxiedApiModule", () => {
|
|||
expect(api.translations).toBe(translations);
|
||||
});
|
||||
|
||||
it("should overwriteAccountAuth", async () => {
|
||||
const dispatchSpy = jest.spyOn(defaultDispatcher, "dispatch");
|
||||
|
||||
const api = new ProxiedModuleApi();
|
||||
const accountInfo = {} as unknown as AccountAuthInfo;
|
||||
const promise = api.overwriteAccountAuth(accountInfo);
|
||||
|
||||
expect(dispatchSpy).toHaveBeenCalledWith(
|
||||
expect.objectContaining({
|
||||
action: Action.OverwriteLogin,
|
||||
credentials: {
|
||||
...accountInfo,
|
||||
guest: false,
|
||||
},
|
||||
}),
|
||||
expect.anything(),
|
||||
);
|
||||
|
||||
defaultDispatcher.fire(Action.OnLoggedIn);
|
||||
|
||||
await expect(promise).resolves.toBeUndefined();
|
||||
});
|
||||
|
||||
describe("integration", () => {
|
||||
it("should translate strings using translation system", async () => {
|
||||
// Test setup
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue