@riligar/auth-react 1.33.0 → 1.34.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.esm.js +16 -24
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +16 -24
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -368,35 +368,27 @@ const useAuthStore = zustand.create((set, get) => ({
|
|
|
368
368
|
},
|
|
369
369
|
/* Init ao montar o Provider */
|
|
370
370
|
init: async () => {
|
|
371
|
-
const {
|
|
372
|
-
fetchApplicationInfo
|
|
373
|
-
} = get();
|
|
374
371
|
try {
|
|
375
|
-
//
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
372
|
+
// Busca a sessão (que agora também traz applicationInfo)
|
|
373
|
+
const sessionData = await getSession();
|
|
374
|
+
|
|
375
|
+
// Se veio aplicação no redirecionamento/sessão, salva no store
|
|
376
|
+
if (sessionData?.application) {
|
|
377
|
+
set({
|
|
378
|
+
applicationInfo: sessionData.application
|
|
379
|
+
});
|
|
379
380
|
}
|
|
380
381
|
let user = null;
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
}
|
|
389
|
-
if (sessionData?.session) {
|
|
390
|
-
set({
|
|
391
|
-
currentSession: sessionData.session
|
|
392
|
-
});
|
|
393
|
-
}
|
|
394
|
-
} catch (sessionError) {
|
|
395
|
-
// Se falhar (401), continua para verificar localStorage token
|
|
396
|
-
console.log('[AuthStore] Server session not found, checking local token');
|
|
382
|
+
if (sessionData?.user) {
|
|
383
|
+
user = sessionData.user;
|
|
384
|
+
}
|
|
385
|
+
if (sessionData?.session) {
|
|
386
|
+
set({
|
|
387
|
+
currentSession: sessionData.session
|
|
388
|
+
});
|
|
397
389
|
}
|
|
398
390
|
|
|
399
|
-
//
|
|
391
|
+
// Se não encontrou sessão via cookies, verifica localStorage token (JWT)
|
|
400
392
|
if (!user && isAuthenticated()) {
|
|
401
393
|
user = getCurrentUser();
|
|
402
394
|
}
|