Phase 1 reliability/stabilisation: auth logging, logout client, loader+xml hardening
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
import { destroyCookie } from "nookies";
|
||||
import { signOut } from "next-auth/react";
|
||||
|
||||
const AUTH_COOKIE_NAMES = [
|
||||
"next-auth.csrf-token",
|
||||
"next-auth.callback-url",
|
||||
"__Secure-next-auth.callback-url",
|
||||
"pedw_locale",
|
||||
"pinsUser"
|
||||
];
|
||||
|
||||
export const clearClientSessionArtifacts = () => {
|
||||
if (typeof window !== "undefined") {
|
||||
window.localStorage.clear();
|
||||
}
|
||||
|
||||
AUTH_COOKIE_NAMES.forEach((cookieName) => {
|
||||
destroyCookie(null, cookieName, { path: "/" });
|
||||
});
|
||||
};
|
||||
|
||||
export const logoutClient = async (locale) => {
|
||||
clearClientSessionArtifacts();
|
||||
await signOut({
|
||||
callbackUrl: locale === "cy" ? "/cy/allgofnodi" : "/logout"
|
||||
});
|
||||
};
|
||||
Reference in New Issue
Block a user