mirror of
https://github.com/Tria-plc/emaui.git
synced 2026-08-26 19:12:50 +00:00
27 lines
858 B
TypeScript
27 lines
858 B
TypeScript
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 },
|
|
};
|
|
}
|