remote: 59.60 src/access/isAdmin.ts(2,22): error TS2307: Cannot find module '../payload-types' or its corresponding type declarations.
remote: 59.60 src/access/isLoggedIn.ts(2,22): error TS2307: Cannot find module '../payload-types' or its corresponding type declarations.
remote: 59.65 error Command failed with exit code 2.
isAdmin.ts
import { Access, FieldAccess } from "payload/types";
import { User } from "../payload-types";
export const isAdmin: Access<any, User> = ({ req: { user } }) => {
// Return true or false based on if the user has an admin role
return Boolean(user?.roles?.includes('admin'));
}
export const isAdminFieldLevel: FieldAccess<{ id: string }, unknown, User> = ({ req: { user } }) => {
// Return true or false based on if the user has an admin role
return Boolean(user?.roles?.includes('admin'));
}
isLoggedIn.ts
import { Access } from "payload/config";
import { User } from "../payload-types";
export const isLoggedIn: Access<any, User> = ({ req: { user } }) => {
// Return true if user is logged in, false if not
return Boolean(user);
}
Star
Discord
online
Get help straight from the Payload team with an Enterprise License.