Skip to content
Discussion options

You must be logged in to vote

I did exactly this

here's my code

const permissions = new Elysia({name: 'permissions'})
.macro({
  permissions(permissions: Record<string, string[]>) {
    return {
      async resolve({request: { headers }}) {
        try {
          const hasPermission = await auth.api.hasPermission({
            headers: headers,
            body: {
              permissions
            }
          });
          
          if (!hasPermission.success) {
            throw new UnauthorizedException('You do not have permission to access this resource');
          }
        } catch (error) {
          if (error instanceof UnauthorizedException) {
            // Re-throw permission errors
            throw e…

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@brielov
Comment options

@ihsanmohamad
Comment options

Answer selected by brielov
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants