Files
openpanel/packages/devtools-ui/src/utils/auth.ts
Stefan Pejcic 09f9f9502d packages
2024-11-07 19:03:37 +01:00

29 lines
561 B
TypeScript

import { ory } from "./ory";
export const isAuthenticated = async () => {
try {
const response = await ory.toSession();
const authenticatedHeader = response.headers["refine-is-authenticated"];
if (authenticatedHeader === "false") {
return false;
}
return true;
} catch (error: any) {
return false;
}
};
export const logoutUser = async () => {
try {
await ory.performNativeLogout({
performNativeLogoutBody: {
session_token: "",
},
});
return true;
} catch (_) {
return false;
}
};