-
Notifications
You must be signed in to change notification settings - Fork 940
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: user existence checks in session object #1587
Conversation
The latest updates on your projects. Learn more about Vercel for Git 鈫楋笌 |
Thank you for following the naming conventions for pull request titles! 馃檹 |
apps/web/app/(app)/environments/[environmentId]/layout.tsxIt's a good practice to check if the session and session.user exist before using it. This can prevent potential null reference exceptions which can lead to application crashes. const session = await getServerSession(authOptions);
if (!session || !session.user) {
return redirect(`/auth/login`);
}
const hasAccess = await hasUserEnvironmentAccess(session.user.id, params.environmentId); apps/web/app/(app)/environments/[environmentId]/settings/profile/page.tsxIt's a good practice to check if the session and session.user exist before using it. This can prevent potential null reference exceptions which can lead to application crashes. const session = await getServerSession(authOptions);
const profile = session && session.user ? await getProfile(session.user.id) : null; |
const session = await getServerSession(authOptions); | ||
const profile = session ? await getProfile(session.user.id) : null; | ||
const profile = session && session.user ? await getProfile(session.user.id) : null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added a check to ensure that the session and session.user exist before using it. This prevents potential null reference exceptions which can lead to application crashes.
const session = await getServerSession(authOptions); | |
const profile = session ? await getProfile(session.user.id) : null; | |
const profile = session && session.user ? await getProfile(session.user.id) : null; | |
const session = await getServerSession(authOptions); | |
const profile = session && session.user ? await getProfile(session.user.id) : null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
馃槉馃檹
What does this PR do?
Sentry runtime errors included these 2 pages where the id of an undefined object was being fetched resulting in a runtime error. This PR handles them both.
Type of change
Checklist
Required
pnpm build
console.logs
git pull origin main
Appreciated