Refresh HiveGrid Cloud reference snapshot
This commit is contained in:
1 parent
5e99e14772
commit
7f88026f79
5955 files changed
+1177325
-188362
No files matched your search
+38
@@ -0,0 +1,38 @@
|
||||
import { getUserTotpStatus } from "~/utils/db/users.db.server";
|
||||
import { commitPendingMfaLoginCookie, type PendingMfaPrimaryMethod } from "~/utils/session.server";
|
||||
|
||||
export const LOGIN_MFA_CHALLENGE_PATH = "/login-mfa";
|
||||
|
||||
export type AlternativeLoginMfaResult =
|
||||
| { required: false }
|
||||
| { required: true; setCookie: string };
|
||||
|
||||
/**
|
||||
* Alternative primary factors without a separately verified upstream MFA
|
||||
* assurance must not silently satisfy a configured second factor. Trusted
|
||||
* device bypass is intentionally excluded from these flows: an enabled TOTP
|
||||
* configuration always transitions to the pending MFA state.
|
||||
*/
|
||||
export async function beginAlternativeLoginMfa({
|
||||
request,
|
||||
userId,
|
||||
redirectTo,
|
||||
primaryMethod,
|
||||
}: {
|
||||
request: Request;
|
||||
userId: string;
|
||||
redirectTo: string;
|
||||
primaryMethod: PendingMfaPrimaryMethod;
|
||||
}): Promise<AlternativeLoginMfaResult> {
|
||||
const status = await getUserTotpStatus(userId);
|
||||
if (!status) {
|
||||
throw new Error("MFA status is unavailable for the authenticated identity");
|
||||
}
|
||||
if (!status.enabled) {
|
||||
return { required: false };
|
||||
}
|
||||
return {
|
||||
required: true,
|
||||
setCookie: await commitPendingMfaLoginCookie(request, { userId, redirectTo, primaryMethod }),
|
||||
};
|
||||
}
|
||||
Reference in new issue
Block a user