Skip to main content

Function: useEprintPermissions()

useEprintPermissions(eprint, userDid): EprintPermissions

Defined in: web/lib/hooks/use-eprint-mutations.ts:287

Determines if the current user can edit/delete an eprint.

Parameters

eprint

Eprint data with submittedBy and optional paperDid

undefined | EprintData

userDid

Current user's DID (undefined if not authenticated)

undefined | string

Returns

EprintPermissions

Permission object with canModify, requiresPaperAuth, and reason

Remarks

For paper-centric eprints (paperDid is set), the user must authenticate as the paper account to modify. For traditional eprints, only the submitter can modify.

Example

const { canModify, requiresPaperAuth, reason } = useEprintPermissions(eprint, userDid);

if (!canModify) {
return <span>You cannot edit this eprint: {reason}</span>;
}

if (requiresPaperAuth) {
return <PaperAuthPrompt paperDid={eprint.paperDid} />;
}

return <EditButton />;