academe-kit 0.8.8 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs
CHANGED
|
@@ -6034,14 +6034,14 @@ const setCookie = (name, value, domain) => {
|
|
|
6034
6034
|
}
|
|
6035
6035
|
document.cookie = cookieParts.join("; ");
|
|
6036
6036
|
};
|
|
6037
|
+
const INITIAL_REDIRECT_URI = typeof window !== "undefined"
|
|
6038
|
+
? `${window.location.origin}${window.location.pathname}`
|
|
6039
|
+
: undefined;
|
|
6037
6040
|
const AcademeAuthProvider = ({ realm, hubUrl, children, clientId, keycloakUrl, apiBaseUrl, redirectUri, skipApiUserFetch, }) => {
|
|
6038
6041
|
const oidcConfig = {
|
|
6039
6042
|
authority: `${keycloakUrl}/realms/${realm}`,
|
|
6040
6043
|
client_id: clientId,
|
|
6041
|
-
redirect_uri: redirectUri ||
|
|
6042
|
-
(typeof window !== "undefined"
|
|
6043
|
-
? window.location.origin
|
|
6044
|
-
: process.env.NEXT_PUBLIC_REDIRECT_URI),
|
|
6044
|
+
redirect_uri: redirectUri || INITIAL_REDIRECT_URI || process.env.NEXT_PUBLIC_REDIRECT_URI,
|
|
6045
6045
|
scope: "openid profile email",
|
|
6046
6046
|
onSigninCallback: () => {
|
|
6047
6047
|
window.history.replaceState({}, document.title, window.location.pathname);
|
|
@@ -6299,14 +6299,32 @@ const SecurityProvider = ({ apiBaseUrl = "https://stg-api.academe.com.br", skipA
|
|
|
6299
6299
|
setIsRefreshing(false);
|
|
6300
6300
|
}, [getKeycloakUser, services, skipApiUserFetch]);
|
|
6301
6301
|
// --- 5. Ações de Auth ---
|
|
6302
|
-
const signOut = React2.useCallback(() => {
|
|
6302
|
+
const signOut = React2.useCallback(async () => {
|
|
6303
6303
|
console.log("[KC LOGOUT!]");
|
|
6304
6304
|
setCurrentUser(null);
|
|
6305
|
+
setAccessToken(undefined);
|
|
6306
|
+
// Limpar cookie KC_FORCE_AUTH_TOKEN
|
|
6307
|
+
if (typeof window !== "undefined") {
|
|
6308
|
+
document.cookie =
|
|
6309
|
+
"KC_FORCE_AUTH_TOKEN=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/; domain=.academe.com.br; secure; SameSite=None";
|
|
6310
|
+
window.accessToken = undefined;
|
|
6311
|
+
}
|
|
6312
|
+
// Limpar storages de dados OIDC do usuário
|
|
6313
|
+
sessionStorage.clear();
|
|
6314
|
+
localStorage.removeItem(`oidc.user:${auth.settings.authority}:${auth.settings.client_id}`);
|
|
6305
6315
|
auth.removeUser();
|
|
6306
|
-
auth.signoutRedirect({
|
|
6307
|
-
id_token_hint: auth.user?.id_token,
|
|
6308
|
-
});
|
|
6309
6316
|
auth.clearStaleState();
|
|
6317
|
+
// Fazer logout silencioso no Keycloak e redirecionar para login
|
|
6318
|
+
try {
|
|
6319
|
+
await auth.signoutSilent({
|
|
6320
|
+
id_token_hint: auth.user?.id_token,
|
|
6321
|
+
});
|
|
6322
|
+
}
|
|
6323
|
+
catch (error) {
|
|
6324
|
+
console.debug("[KC LOGOUT] Silent signout failed, redirecting to login anyway:", error);
|
|
6325
|
+
}
|
|
6326
|
+
// Redirecionar para a tela de login
|
|
6327
|
+
auth.signinRedirect();
|
|
6310
6328
|
}, [auth]);
|
|
6311
6329
|
const hasSchool = React2.useCallback((schoolId) => {
|
|
6312
6330
|
if (hasRealmRole(exports.GLOBAL_ROLES.ADMIN_ACADEME)) {
|