Updated the batch user creation to work without corporate
This commit is contained in:
@@ -32,6 +32,7 @@ import { getEntitiesWithRoles, getEntityWithRoles } from "@/utils/entities.be";
|
||||
import { mapBy, serialize, redirect } from "@/utils";
|
||||
import { EntityWithRoles } from "@/interfaces/entity";
|
||||
import { requestUser } from "@/utils/api";
|
||||
import { isAdmin } from "@/utils/users";
|
||||
|
||||
export const getServerSideProps = withIronSessionSsr(async ({ req, res }) => {
|
||||
const user = await requestUser(req, res)
|
||||
@@ -41,7 +42,7 @@ export const getServerSideProps = withIronSessionSsr(async ({ req, res }) => {
|
||||
return redirect("/")
|
||||
|
||||
const permissions = await getUserPermissions(user.id);
|
||||
const entities = await getEntitiesWithRoles(mapBy(user.entities, 'id')) || []
|
||||
const entities = isAdmin(user) ? await getEntitiesWithRoles() : await getEntitiesWithRoles(mapBy(user.entities, 'id'))
|
||||
|
||||
return {
|
||||
props: serialize({ user, permissions, entities }),
|
||||
|
||||
Reference in New Issue
Block a user