@riligar/auth-react 1.19.0 → 1.20.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/README.md +4 -0
- package/dist/index.esm.js +14 -28
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +14 -28
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -102,17 +102,8 @@ function setStoredToken(token) {
|
|
|
102
102
|
function handleAuthResponse(result) {
|
|
103
103
|
// Tenta encontrar o token em vários lugares possíveis
|
|
104
104
|
const token = result.token || result.session?.token || result.session?.sessionToken;
|
|
105
|
-
console.log('[AuthSDK] Handling Auth Response:', {
|
|
106
|
-
hasToken: !!result.token,
|
|
107
|
-
hasSessionToken: !!result.session?.token,
|
|
108
|
-
hasSessionSessionToken: !!result.session?.sessionToken,
|
|
109
|
-
extractedToken: token
|
|
110
|
-
});
|
|
111
105
|
if (token) {
|
|
112
|
-
console.log('[AuthSDK] Saving token to storage');
|
|
113
106
|
setStoredToken(token);
|
|
114
|
-
} else {
|
|
115
|
-
console.warn('[AuthSDK] No token found in response', result);
|
|
116
107
|
}
|
|
117
108
|
return result;
|
|
118
109
|
}
|
|
@@ -362,7 +353,7 @@ const useAuthStore = zustand.create((set, get) => ({
|
|
|
362
353
|
changePassword: false,
|
|
363
354
|
changeEmail: false,
|
|
364
355
|
listSessions: false,
|
|
365
|
-
revokeSession:
|
|
356
|
+
revokeSession: null // null or sessionId being revoked
|
|
366
357
|
},
|
|
367
358
|
// Application info (logo, nome, etc)
|
|
368
359
|
applicationInfo: null,
|
|
@@ -706,40 +697,35 @@ const useAuthStore = zustand.create((set, get) => ({
|
|
|
706
697
|
sessions,
|
|
707
698
|
signOut
|
|
708
699
|
} = get();
|
|
709
|
-
setLoading('revokeSession',
|
|
700
|
+
setLoading('revokeSession', sessionId);
|
|
710
701
|
set({
|
|
711
702
|
error: null
|
|
712
703
|
});
|
|
713
704
|
try {
|
|
714
|
-
console.log('[AuthStore] Revoking session:', {
|
|
715
|
-
targetId: sessionId,
|
|
716
|
-
currentId: currentSession?.id,
|
|
717
|
-
totalSessions: sessions.length
|
|
718
|
-
});
|
|
719
|
-
|
|
720
705
|
// Detect if current session OR last remaining session
|
|
721
706
|
const isCurrent = sessionId === currentSession?.id;
|
|
722
707
|
const isLast = sessions.length === 1 && sessions[0].id === sessionId;
|
|
723
708
|
|
|
724
709
|
// Se for a sessão atual ou a última, faz logout normal
|
|
725
710
|
if (isCurrent || isLast) {
|
|
726
|
-
console.log('[AuthStore] Revoking current/last session -> Executing signOut');
|
|
727
711
|
await signOut();
|
|
728
712
|
// signOut já limpa loading states e erros no finally, mas
|
|
729
713
|
// como estamos dentro do fluxo deste método, garantimos:
|
|
730
|
-
setLoading('revokeSession',
|
|
714
|
+
setLoading('revokeSession', null);
|
|
731
715
|
return;
|
|
732
716
|
}
|
|
733
717
|
await revokeSession(sessionId);
|
|
734
718
|
|
|
735
|
-
//
|
|
736
|
-
|
|
737
|
-
|
|
719
|
+
// Remove a sessão revogada da lista local
|
|
720
|
+
set(state => ({
|
|
721
|
+
sessions: state.sessions.filter(s => s.id !== sessionId)
|
|
722
|
+
}));
|
|
723
|
+
setLoading('revokeSession', null);
|
|
738
724
|
} catch (err) {
|
|
739
725
|
set({
|
|
740
726
|
error: err
|
|
741
727
|
});
|
|
742
|
-
setLoading('revokeSession',
|
|
728
|
+
setLoading('revokeSession', null);
|
|
743
729
|
throw err;
|
|
744
730
|
}
|
|
745
731
|
},
|
|
@@ -748,7 +734,7 @@ const useAuthStore = zustand.create((set, get) => ({
|
|
|
748
734
|
setLoading,
|
|
749
735
|
listSessions
|
|
750
736
|
} = get();
|
|
751
|
-
setLoading('revokeSession',
|
|
737
|
+
setLoading('revokeSession', 'all');
|
|
752
738
|
set({
|
|
753
739
|
error: null
|
|
754
740
|
});
|
|
@@ -756,12 +742,12 @@ const useAuthStore = zustand.create((set, get) => ({
|
|
|
756
742
|
await revokeOtherSessions();
|
|
757
743
|
// Refresh sessions list after revocation
|
|
758
744
|
await listSessions();
|
|
759
|
-
setLoading('revokeSession',
|
|
745
|
+
setLoading('revokeSession', null);
|
|
760
746
|
} catch (err) {
|
|
761
747
|
set({
|
|
762
748
|
error: err
|
|
763
749
|
});
|
|
764
|
-
setLoading('revokeSession',
|
|
750
|
+
setLoading('revokeSession', null);
|
|
765
751
|
throw err;
|
|
766
752
|
}
|
|
767
753
|
},
|
|
@@ -2930,7 +2916,7 @@ function UserProfile({
|
|
|
2930
2916
|
color: "red",
|
|
2931
2917
|
size: "xs",
|
|
2932
2918
|
onClick: () => handleRevokeSession(sessionItem.id),
|
|
2933
|
-
loading: loadingRevokeSession,
|
|
2919
|
+
loading: loadingRevokeSession === sessionItem.id,
|
|
2934
2920
|
leftSection: /*#__PURE__*/jsxRuntime.jsx(iconsReact.IconLogout, {
|
|
2935
2921
|
size: 14
|
|
2936
2922
|
}),
|
|
@@ -2946,7 +2932,7 @@ function UserProfile({
|
|
|
2946
2932
|
color: "red",
|
|
2947
2933
|
size: "xs",
|
|
2948
2934
|
onClick: handleRevokeOtherSessions,
|
|
2949
|
-
loading: loadingRevokeSession,
|
|
2935
|
+
loading: loadingRevokeSession === 'all',
|
|
2950
2936
|
leftSection: /*#__PURE__*/jsxRuntime.jsx(iconsReact.IconLogout, {
|
|
2951
2937
|
size: 14
|
|
2952
2938
|
}),
|