mirror of
https://github.com/Portabase/portabase.git
synced 2026-07-14 11:16:13 +02:00
Working on create organization and delete.
This commit is contained in:
@@ -2,8 +2,43 @@
|
||||
|
||||
import {redirect} from "next/navigation";
|
||||
import {signIn, signOut} from "@/auth/auth";
|
||||
import {getServerUrl} from "@/utils/get-server-url";
|
||||
//
|
||||
// const baseUrl = getServerUrl();
|
||||
// async function fetchCsrfToken() {
|
||||
// const response = await fetch(`${baseUrl}/api/auth/csrf`);
|
||||
// const data = await response.json();
|
||||
// return data.csrfToken;
|
||||
// }
|
||||
//
|
||||
// async function manualSignOut() {
|
||||
// const csrfToken = await fetchCsrfToken();
|
||||
//
|
||||
// const formData = new URLSearchParams();
|
||||
// formData.append('csrfToken', csrfToken);
|
||||
// formData.append('json', 'true');
|
||||
//
|
||||
// const response = await fetch(`${baseUrl}/api/auth/signout`, {
|
||||
// method: 'POST',
|
||||
// headers: {
|
||||
// 'Content-Type': 'application/x-www-form-urlencoded',
|
||||
// },
|
||||
// body: formData.toString(),
|
||||
// });
|
||||
//
|
||||
// if (response.ok) {
|
||||
// console.log('Signed out successfully');
|
||||
// window.location.reload();
|
||||
//
|
||||
// } else {
|
||||
// console.error('Failed to sign out');
|
||||
// }
|
||||
// }
|
||||
//
|
||||
|
||||
|
||||
export const signOutAction = async () => {
|
||||
// await manualSignOut()
|
||||
await signOut({redirectTo: '/', redirect: true})
|
||||
window.location.reload();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
|
||||
|
||||
export async function checkAllPermissions(db: any, model: string) {
|
||||
const operations = ['read', 'create', 'update', 'delete'];
|
||||
const results: Record<string, boolean> = {};
|
||||
|
||||
for (const operation of operations) {
|
||||
// Dynamically access the model and check permissions
|
||||
results[operation] = await db[model].check({ operation });
|
||||
}
|
||||
|
||||
const hasAllPermissions = Object.values(results).every(permission => permission === true);
|
||||
|
||||
console.log('Permissions:', results);
|
||||
console.log('Has all permissions:', hasAllPermissions);
|
||||
|
||||
return hasAllPermissions;
|
||||
}
|
||||
Reference in New Issue
Block a user