* fix: correct admin password banner message to require both password length and 2FA The banner message incorrectly used 'or' implying only one condition was needed, but the code requires BOTH a password of at least 15 characters AND 2FA enabled. Updated the message to clearly state both requirements and added a hint that users need to log out and log back in after updating their security settings. Fixes #9527 Co-Authored-By: unknown <> * fix: auto-sign-out INACTIVE_ADMIN users after enabling 2FA When an INACTIVE_ADMIN user enables 2FA, automatically sign them out so they can log back in with refreshed session role, dismissing the banner. This matches the existing behavior for password changes. Co-Authored-By: unknown <> * feat: add dynamic admin banner message based on inactiveAdminReason Co-Authored-By: unknown <> * Remove and add various localization strings * Update common.json * Add cookie consent checkbox message and remove entries * test: add unit tests for AdminPasswordBanner and inactiveAdminReason logic Co-Authored-By: unknown <> * fix: add expires field to session mock to fix type check Co-Authored-By: unknown <> * fix: wrap CALENDSO_ENCRYPTION_KEY mutations in try/finally to prevent env state leaks Addresses Cubic AI review feedback (confidence 9/10): when a test fails early, the CALENDSO_ENCRYPTION_KEY env var was not being restored, which could leak state into subsequent tests. Wrapped the env mutation in try/finally blocks to guarantee cleanup. Co-Authored-By: bot_apk <apk@cognition.ai> * fix: add missing 'expires' field to buildSession in AdminPasswordBanner test The Session type requires 'expires' to be a string, but buildSession was not providing it, causing a type error caught by CI type-check. Co-Authored-By: bot_apk <apk@cognition.ai> --------- Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Co-authored-by: bot_apk <apk@cognition.ai>
83 lines
2.2 KiB
TypeScript
83 lines
2.2 KiB
TypeScript
import type { DefaultUser } from "next-auth";
|
|
|
|
import type { User as PrismaUser, UserPermissionRole } from "@calcom/prisma/client";
|
|
import type { MembershipRole } from "@calcom/prisma/enums";
|
|
|
|
import type { UserProfile } from "./UserProfile";
|
|
|
|
declare module "next-auth" {
|
|
/**
|
|
* Returned by `useSession`, `getSession` and received as a prop on the `Provider` React Context
|
|
*/
|
|
interface Session {
|
|
hasValidLicense: boolean;
|
|
profileId?: number | null;
|
|
upId: string;
|
|
user: User & { uuid: PrismaUser["uuid"] };
|
|
}
|
|
|
|
interface User extends Omit<DefaultUser, "id"> {
|
|
id: PrismaUser["id"];
|
|
uuid?: PrismaUser["uuid"];
|
|
emailVerified?: PrismaUser["emailVerified"];
|
|
email_verified?: boolean;
|
|
completedOnboarding?: boolean;
|
|
impersonatedBy?: {
|
|
id: number;
|
|
uuid: string;
|
|
role: PrismaUser["role"];
|
|
};
|
|
belongsToActiveTeam?: boolean;
|
|
org?: {
|
|
id: number;
|
|
name?: string;
|
|
slug: string;
|
|
logoUrl?: string | null;
|
|
fullDomain: string;
|
|
domainSuffix: string;
|
|
role: MembershipRole;
|
|
};
|
|
username?: PrismaUser["username"];
|
|
orgAwareUsername?: PrismaUser["username"];
|
|
avatarUrl?: PrismaUser["avatarUrl"];
|
|
role?: PrismaUser["role"] | "INACTIVE_ADMIN";
|
|
/** Set when role is INACTIVE_ADMIN: why admin security requirements are not met */
|
|
inactiveAdminReason?: "both" | "password" | "2fa";
|
|
locale?: string | null;
|
|
profile?: UserProfile;
|
|
samlTenant?: string;
|
|
}
|
|
}
|
|
|
|
declare module "next-auth/jwt" {
|
|
interface JWT {
|
|
id?: string | number;
|
|
name?: string | null;
|
|
username?: string | null;
|
|
avatarUrl?: string | null;
|
|
email?: string | null;
|
|
upId?: string;
|
|
profileId?: number | null;
|
|
role?: UserPermissionRole | "INACTIVE_ADMIN" | null;
|
|
inactiveAdminReason?: "both" | "password" | "2fa";
|
|
impersonatedBy?: {
|
|
id: number;
|
|
uuid: string;
|
|
role: PrismaUser["role"];
|
|
};
|
|
belongsToActiveTeam?: boolean;
|
|
org?: {
|
|
id: number;
|
|
name?: string;
|
|
slug: string;
|
|
logoUrl?: string | null;
|
|
fullDomain: string;
|
|
domainSuffix: string;
|
|
role: MembershipRole;
|
|
};
|
|
orgAwareUsername?: PrismaUser["username"];
|
|
organizationId?: number | null;
|
|
locale?: string;
|
|
}
|
|
}
|