mirror of
https://github.com/webstudio-is/webstudio.git
synced 2026-10-29 08:07:48 +09:00
23 lines
720 B
TypeScript
23 lines
720 B
TypeScript
import { authorizeProject } from "@webstudio-is/trpc-interface/index.server";
|
|
import { createPostgrestContext } from "~/shared/context.server";
|
|
|
|
/**
|
|
* Check if a user is authorized to access a project during the Builder authentication process.
|
|
*/
|
|
export const isUserAuthorizedForProject = async (
|
|
userId: string,
|
|
projectId: string
|
|
) => {
|
|
const postgrestContext = createPostgrestContext();
|
|
|
|
// Only the project owner can access the Builder URL with authentication credentials (session).
|
|
const isProjectOwner = await authorizeProject.checkProjectPermit({
|
|
projectId,
|
|
permit: "own",
|
|
authInfo: { type: "user", userId },
|
|
postgrestClient: postgrestContext.client,
|
|
});
|
|
|
|
return isProjectOwner;
|
|
};
|