Summary
On production and staging when the agent/:id redirect was live, the user even if they were Coordinator or Admin would be redirected and unable to access the profile.
Steps to Reproduce
- Paste the following in
src/app/[lang]/dashboard/agents/[id]/page.tsx
import ProfileLayout from "@/components/Dashboard/Profile/ProfileLayout";
import { getServerUserRole } from "@/hooks/api/getUserRole";
import { RouteParams } from "@/types";
import { UserRole } from "need4deed-sdk";
import { cookies } from "next/headers";
import { redirect } from "next/navigation";
export default async function DashboardAgentPage({ params }: RouteParams) {
const { id } = await params;
const cookieStore = await cookies();
const cookieHeader = cookieStore.toString();
const userRole = await getServerUserRole(cookieHeader);
if (!userRole || (userRole !== UserRole.COORDINATOR && userRole !== UserRole.ADMIN)) {
redirect(`/dashboard/agents`);
}
return <ProfileLayout entityId={id} entityType="agent" />;
}
- Change role of account to either
COORDINATOR or ADMIN (if not already)
- Navigate to an agent profile
- Observe redirect
Expected Behavior
If user is COORDINATOR or ADMIN, there should be no redirect
If user is AGENT or VOLUNTEER, there should be a redirect
Actual Behavior
local dev
If user is COORDINATOR or ADMIN, there is no redirect
If user is AGENT or VOLUNTEER, there is a redirect
staging
If user is COORDINATOR or ADMIN, there is a redirect
If user is AGENT or VOLUNTEER, there is a redirect
production
If user is COORDINATOR or ADMIN, there is a redirect
If user is AGENT or VOLUNTEER, there is a redirect
Environment
Incorrect redirect was recorded on:
Summary
On production and staging when the
agent/:idredirect was live, the user even if they wereCoordinatororAdminwould be redirected and unable to access the profile.Steps to Reproduce
src/app/[lang]/dashboard/agents/[id]/page.tsxCOORDINATORorADMIN(if not already)Expected Behavior
If user is
COORDINATORorADMIN, there should be no redirectIf user is
AGENTorVOLUNTEER, there should be a redirectActual Behavior
local dev
If user is
COORDINATORorADMIN, there is no redirectIf user is
AGENTorVOLUNTEER, there is a redirectstaging
If user is
COORDINATORorADMIN, there is a redirectIf user is
AGENTorVOLUNTEER, there is a redirectproduction
If user is
COORDINATORorADMIN, there is a redirectIf user is
AGENTorVOLUNTEER, there is a redirectEnvironment
Incorrect redirect was recorded on: