@squiz/resource-browser 3.3.4 → 3.3.5
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/CHANGELOG.md +6 -0
- package/lib/Hooks/useAuth.js +2 -0
- package/package.json +1 -1
- package/src/Hooks/useAuth.ts +3 -1
package/CHANGELOG.md
CHANGED
package/lib/Hooks/useAuth.js
CHANGED
@@ -17,6 +17,8 @@ const useAuth = (authConfig) => {
|
|
17
17
|
catch {
|
18
18
|
setAuthToken(null);
|
19
19
|
setIsAuthenticated(false);
|
20
|
+
// Clear cookies associated with invalidated tokens
|
21
|
+
(0, authUtils_1.logout)();
|
20
22
|
throw new Error('Session expired. Please log in again.');
|
21
23
|
}
|
22
24
|
}, [authConfig]);
|
package/package.json
CHANGED
package/src/Hooks/useAuth.ts
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
/* eslint-disable no-console */
|
2
2
|
import { useState, useCallback, useEffect } from 'react';
|
3
3
|
import { AuthenticationConfiguration } from '../types';
|
4
|
-
import { getCookieValue, refreshAccessToken as refreshTokenUtil } from '../utils/authUtils';
|
4
|
+
import { getCookieValue, refreshAccessToken as refreshTokenUtil, logout } from '../utils/authUtils';
|
5
5
|
|
6
6
|
export const useAuth = (authConfig: AuthenticationConfiguration | undefined) => {
|
7
7
|
const [authToken, setAuthToken] = useState<string | null>(getCookieValue('authToken'));
|
@@ -16,6 +16,8 @@ export const useAuth = (authConfig: AuthenticationConfiguration | undefined) =>
|
|
16
16
|
} catch {
|
17
17
|
setAuthToken(null);
|
18
18
|
setIsAuthenticated(false);
|
19
|
+
// Clear cookies associated with invalidated tokens
|
20
|
+
logout();
|
19
21
|
throw new Error('Session expired. Please log in again.');
|
20
22
|
}
|
21
23
|
}, [authConfig]);
|