nextauthz 1.2.3 → 1.2.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/dist/index.js +1 -1
- package/dist/index.mjs +1 -1
- package/package.json +1 -1
- package/readme.md +3 -4
- package/src/AuthProvider.tsx +4 -3
package/dist/index.js
CHANGED
|
@@ -93,7 +93,7 @@ function createAuthContext(option) {
|
|
|
93
93
|
resetAuth();
|
|
94
94
|
}
|
|
95
95
|
setAuthChecked(true);
|
|
96
|
-
}, [
|
|
96
|
+
}, [tokenKey]);
|
|
97
97
|
const login = (tokens, userData, role2) => {
|
|
98
98
|
const tokenValue = tokens[tokenKey] ?? tokens["access_token"] ?? Object.values(tokens)[0];
|
|
99
99
|
manager.setTokens({
|
package/dist/index.mjs
CHANGED
|
@@ -66,7 +66,7 @@ function createAuthContext(option) {
|
|
|
66
66
|
resetAuth();
|
|
67
67
|
}
|
|
68
68
|
setAuthChecked(true);
|
|
69
|
-
}, [
|
|
69
|
+
}, [tokenKey]);
|
|
70
70
|
const login = (tokens, userData, role2) => {
|
|
71
71
|
const tokenValue = tokens[tokenKey] ?? tokens["access_token"] ?? Object.values(tokens)[0];
|
|
72
72
|
manager.setTokens({
|
package/package.json
CHANGED
package/readme.md
CHANGED
|
@@ -31,10 +31,9 @@ Wrap your application with AuthProvider to provide global auth state (user, load
|
|
|
31
31
|
import { createAppAuth } from 'nextauthz'
|
|
32
32
|
|
|
33
33
|
// Choose storage type
|
|
34
|
-
const { AuthProvider, useAuth } =
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
})
|
|
34
|
+
const { AuthProvider, useAuth } = createAppAuth('cookie', 'access_token')
|
|
35
|
+
|
|
36
|
+
|
|
38
37
|
// Options: 'localStorage' | 'sessionStorage' | 'cookie'
|
|
39
38
|
// Defaults to 'cookie' if no storage is passed
|
|
40
39
|
|
package/src/AuthProvider.tsx
CHANGED
|
@@ -56,7 +56,7 @@ export function createAuthContext<UserType extends User = User>(option?: {
|
|
|
56
56
|
useEffect(() => {
|
|
57
57
|
const storedUser = manager.getSingleToken('user')
|
|
58
58
|
const token = manager.getSingleToken(tokenKey)
|
|
59
|
-
|
|
59
|
+
|
|
60
60
|
if (storedUser && token && !manager.isExpired(token)) {
|
|
61
61
|
try {
|
|
62
62
|
const parsedUser = JSON.parse(storedUser) as UserType
|
|
@@ -69,9 +69,10 @@ export function createAuthContext<UserType extends User = User>(option?: {
|
|
|
69
69
|
} else {
|
|
70
70
|
resetAuth()
|
|
71
71
|
}
|
|
72
|
-
|
|
72
|
+
|
|
73
73
|
setAuthChecked(true)
|
|
74
|
-
|
|
74
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
75
|
+
}, [tokenKey])
|
|
75
76
|
|
|
76
77
|
/* ---------------------------------- */
|
|
77
78
|
/* Login */
|