mirror of
https://codeberg.org/MarkusThielker/next-ory.git
synced 2025-04-19 09:01:18 +00:00
NORY-46: protect create-client page with permissions
This commit is contained in:
parent
222a93886b
commit
96b1af1ce0
1 changed files with 12 additions and 0 deletions
|
@ -1,7 +1,19 @@
|
||||||
import { CreateClientForm } from '@/components/forms/client-form';
|
import { CreateClientForm } from '@/components/forms/client-form';
|
||||||
import { createClient } from '@/lib/action/client';
|
import { createClient } from '@/lib/action/client';
|
||||||
|
import { checkPermission, requireSession } from '@/lib/action/authentication';
|
||||||
|
import { permission, relation } from '@/lib/permission';
|
||||||
|
import { redirect } from 'next/navigation';
|
||||||
|
|
||||||
export default async function CreateClientPage() {
|
export default async function CreateClientPage() {
|
||||||
|
|
||||||
|
const session = await requireSession();
|
||||||
|
const identityId = session.identity!.id;
|
||||||
|
|
||||||
|
const pmCreateClient = await checkPermission(permission.client.it, relation.create, identityId);
|
||||||
|
if (!pmCreateClient) {
|
||||||
|
return redirect('/client');
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="space-y-4">
|
<div className="space-y-4">
|
||||||
<div>
|
<div>
|
||||||
|
|
Loading…
Add table
Reference in a new issue