fix: Introduce a new prop in the session to extract the profile username when inside an org (#18979)
* fix: flaky test organization.spec * fix: use profile.username * update * update * update
This commit is contained in:
@@ -99,6 +99,7 @@ export async function getServerSession(options: {
|
||||
}),
|
||||
belongsToActiveTeam: token.belongsToActiveTeam,
|
||||
org: token.org,
|
||||
orgAwareUsername: token.orgAwareUsername,
|
||||
locale: user.locale ?? undefined,
|
||||
profile: user.profile,
|
||||
},
|
||||
|
||||
@@ -546,6 +546,7 @@ export const getOptions = ({
|
||||
profileId: profile.id,
|
||||
upId,
|
||||
belongsToActiveTeam,
|
||||
orgAwareUsername: profileOrg ? profile.username : existingUser.username,
|
||||
// All organizations in the token would be too big to store. It breaks the sessions request.
|
||||
// So, we just set the currently switched organization only here.
|
||||
// platform org user don't need profiles nor domains
|
||||
@@ -580,6 +581,7 @@ export const getOptions = ({
|
||||
id: user.id,
|
||||
name: user.name,
|
||||
username: user.username,
|
||||
orgAwareUsername: user?.org ? user.profile?.username : user.username,
|
||||
email: user.email,
|
||||
role: user.role,
|
||||
impersonatedBy: user.impersonatedBy,
|
||||
@@ -684,6 +686,7 @@ export const getOptions = ({
|
||||
impersonatedBy: token.impersonatedBy,
|
||||
belongsToActiveTeam: token?.belongsToActiveTeam as boolean,
|
||||
org: token?.org,
|
||||
orgAwareUsername: token.orgAwareUsername,
|
||||
locale: existingUser.locale,
|
||||
} as JWT;
|
||||
}
|
||||
@@ -709,6 +712,7 @@ export const getOptions = ({
|
||||
id: token.id as number,
|
||||
name: token.name,
|
||||
username: token.username as string,
|
||||
orgAwareUsername: token.orgAwareUsername,
|
||||
role: token.role as UserPermissionRole,
|
||||
impersonatedBy: token.impersonatedBy,
|
||||
belongsToActiveTeam: token?.belongsToActiveTeam as boolean,
|
||||
|
||||
@@ -57,7 +57,7 @@ export function SideBar({ bannersHeight, user }: SideBarProps) {
|
||||
const isPlatformPages = pathname?.startsWith("/settings/platform");
|
||||
const isAdmin = session.data?.user.role === UserPermissionRole.ADMIN;
|
||||
|
||||
const publicPageUrl = `${getBookerBaseUrlSync(user?.org?.slug ?? null)}/${user?.username}`;
|
||||
const publicPageUrl = `${getBookerBaseUrlSync(user?.org?.slug ?? null)}/${user?.orgAwareUsername}`;
|
||||
|
||||
const bottomNavItems = useBottomNavItems({
|
||||
publicPageUrl,
|
||||
|
||||
Vendored
+2
@@ -35,6 +35,7 @@ declare module "next-auth" {
|
||||
role: MembershipRole;
|
||||
};
|
||||
username?: PrismaUser["username"];
|
||||
orgAwareUsername?: PrismaUser["username"];
|
||||
avatarUrl?: PrismaUser["avatarUrl"];
|
||||
role?: PrismaUser["role"] | "INACTIVE_ADMIN";
|
||||
locale?: string | null;
|
||||
@@ -66,6 +67,7 @@ declare module "next-auth/jwt" {
|
||||
domainSuffix: string;
|
||||
role: MembershipRole;
|
||||
};
|
||||
orgAwareUsername?: PrismaUser["username"];
|
||||
organizationId?: number | null;
|
||||
locale?: string;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user