feat: implement two-factor authentication flow during sign-in and add utility hooks for configuration management

This commit is contained in:
estifanos
2026-08-19 10:42:30 +00:00
parent 6117f9c862
commit ff89b9af5e
11 changed files with 170 additions and 38 deletions

View File

@@ -0,0 +1,26 @@
type AccountConfig = { id: string; isMFARequired: boolean };
/**
* Picks the request that persists the two-step verification setting.
*
* `set-my-config` only ever creates, and `iam.account_configurations` is unique
* per user — so an existing record has to be updated through PUT. Getting this
* backwards works exactly once and then fails on the unique constraint, which
* is why the choice lives here, apart from the hook, with a test on it.
*/
export function twoFactorRequest(
config: AccountConfig | undefined,
isMFARequired: boolean,
) {
return config
? {
url: `/account-configurations/my-config/${config.id}`,
method: "PUT" as const,
body: { isMFARequired },
}
: {
url: "/account-configurations/set-my-config",
method: "POST" as const,
body: { isMFARequired },
};
}