mirror of
https://github.com/Termix-SSH/Termix.git
synced 2026-10-29 06:35:24 +00:00
fix(auth): allow retrying unavailable second-factor interfaces (#1549)
This commit is contained in:
1 parent
c66702deb1
commit
c9a1348836
6 files changed
+79
-7
No files matched your search
@@ -71,6 +71,7 @@ vi.mock("sonner", () => ({
|
||||
}));
|
||||
|
||||
import { Auth } from "../../auth/Auth";
|
||||
import { startPreLoginPlugins } from "@/plugin-host/loader";
|
||||
import {
|
||||
registerLoginMethod,
|
||||
registerSecondFactor,
|
||||
@@ -270,6 +271,30 @@ describe("login methods on the login screen", () => {
|
||||
}
|
||||
});
|
||||
|
||||
it("recovers an unavailable second-factor UI without restarting the login", async () => {
|
||||
window.history.replaceState({}, "", "/?second_factor=1&second_factors=pin");
|
||||
render(<Auth onLogin={vi.fn()} />);
|
||||
expect(await screen.findByText("auth.secondFactorNoUI")).toBeTruthy();
|
||||
let dispose = () => {};
|
||||
vi.mocked(startPreLoginPlugins).mockImplementationOnce(async () => {
|
||||
dispose = registerSecondFactor({
|
||||
id: "pin",
|
||||
pluginId: "corp",
|
||||
titleKey: "corp.pin",
|
||||
component: () => <span>recovered challenge</span>,
|
||||
});
|
||||
});
|
||||
try {
|
||||
fireEvent.click(screen.getByText("auth.retrySecondFactorUI"));
|
||||
expect(await screen.findByText("recovered challenge")).toBeTruthy();
|
||||
expect(startPreLoginPlugins).toHaveBeenLastCalledWith({
|
||||
retryFailed: true,
|
||||
});
|
||||
} finally {
|
||||
dispose();
|
||||
}
|
||||
});
|
||||
|
||||
it("offers every registered factor when the server lists none", async () => {
|
||||
const dispose = registerSecondFactor({
|
||||
id: "pin",
|
||||
|
||||
Reference in new issue
Block a user