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