mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-20 00:37:35 +00:00
25 lines
784 B
TypeScript
25 lines
784 B
TypeScript
import { TKeyStoreFactory } from "@app/keystore/keystore";
|
|
|
|
export const getIdentityActiveLockoutAuthMethods = async (
|
|
identityId: string,
|
|
keyStore: Pick<TKeyStoreFactory, "getKeysByPattern" | "getItem">
|
|
) => {
|
|
const activeLockouts = await keyStore.getKeysByPattern(`lockout:identity:${identityId}:*`);
|
|
|
|
const activeLockoutAuthMethods = new Set<string>();
|
|
for await (const key of activeLockouts) {
|
|
const parts = key.split(":");
|
|
if (parts.length > 3) {
|
|
const lockoutRaw = await keyStore.getItem(key);
|
|
if (lockoutRaw) {
|
|
const lockout = JSON.parse(lockoutRaw) as { lockedOut: boolean };
|
|
if (lockout.lockedOut) {
|
|
activeLockoutAuthMethods.add(parts[3]);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
return Array.from(activeLockoutAuthMethods);
|
|
};
|