-
Notifications
You must be signed in to change notification settings - Fork 23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Protected Routes / has(), protect(), and <Protect> #48
Comments
I struggled with this as well. At the moment, my workaround for a <script lang="ts">
import ClerkLoaded from "clerk-sveltekit/client/ClerkLoaded.svelte";
import SignedIn from "clerk-sveltekit/client/SignedIn.svelte";
</script>
<ClerkLoaded let:clerk>
<SignedIn>
{#if clerk?.session?.checkAuthorization({ permission: "my:custom:permission" })}
<slot />
{:else}
<div>
You don't have permission to view the content for the selected organization.
</div>
{/if}
</SignedIn>
</ClerkLoaded> |
Hi, just wanted to follow-up and check the status of this request. We would also greatly benefit from implementing this in clerk-sveltekit. |
Once this PR gets merged, you'll be able to protect your routes/components like this: In your server routes: export const load = (event) => {
const { has } = event.locals.auth
if (!has({ permission: 'org:widgets:create' })) {
// ...
}
// ...
} and in your components: <script>
import Protect from 'clerk-sveltekit/client/Protect.svelte'
</script>
<nav>
<a href="/">Home</a>
<a href="/widgets">Widgets</a>
<Protect role="org:admin">
<a href="/admin">Admin Panel</a>
</Protect>
</nav> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
How would one use
has()
,protect()
, and<Protect>
with clerk-sveltekit?It's not yet implemented if I'm correct?
Here's a link to Clerks Blog post about it: https://clerk.com/blog/introducing-authorization
The text was updated successfully, but these errors were encountered: