diff --git a/src/app/(student)/layout.tsx b/src/app/(student)/layout.tsx index 69e42d5..c570fce 100644 --- a/src/app/(student)/layout.tsx +++ b/src/app/(student)/layout.tsx @@ -11,12 +11,16 @@ export default async function StudentLayout({ children }: { children: React.Reac const session = await auth.api.getSession({ headers: await headers() }); if (!session) redirect("/login"); - // Force password change for auto-provisioned buyers (temp password) + const isImpersonating = !!(session.session as { impersonatedBy?: string }).impersonatedBy; + + // Force password change for auto-provisioned buyers (temp password). + // Skip while an admin is impersonating — they only view the client's cabinet; + // the client sets their own password on a real first login. const dbUser = await prisma.user.findUnique({ where: { id: session.user.id }, select: { mustChangePassword: true }, }); - if (dbUser?.mustChangePassword) redirect("/change-password"); + if (dbUser?.mustChangePassword && !isImpersonating) redirect("/change-password"); // Maintenance mode: non-admin users see the maintenance page if (session.user.role !== "admin") { @@ -35,8 +39,6 @@ export default async function StudentLayout({ children }: { children: React.Reac getSetting("orgRequisites"), ]); - const isImpersonating = !!(session.session as { impersonatedBy?: string }).impersonatedBy; - return (
- Вы вошли с временным паролем. Перед началом работы задайте постоянный — это займёт минуту. -
-+ Вы вошли с временным паролем. Перед началом работы задайте постоянный — это займёт минуту. +
+