export const getServerSideProps: GetServerSideProps<{ user: User }> = async (context) => {
const session = await getServerAuthSession(context)
if (!session) {
return {
redirect: {
destination: '/?errorMessage=session',
permanent: false,
},
}
}
const data = await prisma.orgUsers.findUnique({
where: {
orgId_userId: {
orgId: context.params?.id as string,
userId: session.user.id
}
}
})
if (!data || data.role != 'ADMIN') {
return {
redirect: {
destination: '/?errorMessage=notAdmin',
permanent: false,
},
}
}
return {
props: {
user: session.user
},
}
}
export const getServerSideProps: GetServerSideProps<{ user: User }> = async (context) => {
const session = await getServerAuthSession(context)
if (!session) {
return {
redirect: {
destination: '/?errorMessage=session',
permanent: false,
},
}
}
const data = await prisma.orgUsers.findUnique({
where: {
orgId_userId: {
orgId: context.params?.id as string,
userId: session.user.id
}
}
})
if (!data || data.role != 'ADMIN') {
return {
redirect: {
destination: '/?errorMessage=notAdmin',
permanent: false,
},
}
}
return {
props: {
user: session.user
},
}
}