Working on role in workspace.

This commit is contained in:
charles-gauthereau
2024-12-31 10:54:18 +01:00
parent e1a7ca8558
commit 6f75079a40
29 changed files with 464 additions and 124 deletions
+17 -6
View File
@@ -3,6 +3,7 @@
import {redirect} from "next/navigation";
import {signIn, signOut} from "@/auth/auth";
import {getServerUrl} from "@/utils/get-server-url";
import {deleteOrganizationCookie} from "@/features/dashboard/organization-cookie";
//
// const baseUrl = getServerUrl();
// async function fetchCsrfToken() {
@@ -35,13 +36,23 @@ import {getServerUrl} from "@/utils/get-server-url";
// }
// }
//
export const signOutAction = async () => {
// await manualSignOut()
await signOut({redirectTo: '/', redirect: true})
window.location.reload();
}
const deleteCookieResponse = await deleteOrganizationCookie();
await signOut({ redirectTo: '/', redirect: true });
if (typeof window !== 'undefined') {
window.location.reload();
}
return deleteCookieResponse;
};
//
// export const signOutAction = async () => {
// // await manualSignOut()
// await signOut({redirectTo: '/', redirect: true})
// await deleteOrganizationCookie()
// window.location.reload();
// }
export const signInAction = async (type: string, formData?: any) => {
if (type === "google") {
await signIn(type, {redirectTo: '/dashboard'})
@@ -2,7 +2,6 @@
import {cookies} from 'next/headers';
const COOKIE_NAME = 'PORTABASE_ORGANIZATION_SLUG';
export async function getCurrentOrganizationSlug() {
@@ -11,4 +10,8 @@ export async function getCurrentOrganizationSlug() {
export async function setCurrentOrganizationSlug(slug: string) {
return (await cookies()).set(COOKIE_NAME, slug).get(COOKIE_NAME)?.value;
}
}
export async function deleteOrganizationCookie() {
return (await cookies()).delete(COOKIE_NAME);
}