nextauthz 1.3.0 → 1.3.2
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 +0 -3
- package/dist/index.mjs +0 -3
- package/package.json +1 -1
- package/src/AuthProvider.tsx +7 -15
package/dist/index.js
CHANGED
|
@@ -63,7 +63,6 @@ function createAuthContext(option) {
|
|
|
63
63
|
const AuthProvider = ({ children }) => {
|
|
64
64
|
const storage = option?.storage ?? "cookie";
|
|
65
65
|
const tokenKey = option?.tokenKey ?? "access_token";
|
|
66
|
-
console.log("keys test", tokenKey);
|
|
67
66
|
(0, import_react.useEffect)(() => {
|
|
68
67
|
(0, import_react_token_manager.configureTokenManager)({ storage });
|
|
69
68
|
}, [storage]);
|
|
@@ -81,11 +80,9 @@ function createAuthContext(option) {
|
|
|
81
80
|
(0, import_react.useEffect)(() => {
|
|
82
81
|
const storedUser = manager.getSingleToken("user");
|
|
83
82
|
const token = manager.getSingleToken(tokenKey);
|
|
84
|
-
console.log("token review", token);
|
|
85
83
|
if (token && !manager.isExpired(token)) {
|
|
86
84
|
try {
|
|
87
85
|
setAuth(true);
|
|
88
|
-
console.log("authenticated", isAuthenticated);
|
|
89
86
|
if (storedUser) {
|
|
90
87
|
const parsedUser = JSON.parse(storedUser);
|
|
91
88
|
setUser(parsedUser);
|
package/dist/index.mjs
CHANGED
|
@@ -36,7 +36,6 @@ function createAuthContext(option) {
|
|
|
36
36
|
const AuthProvider = ({ children }) => {
|
|
37
37
|
const storage = option?.storage ?? "cookie";
|
|
38
38
|
const tokenKey = option?.tokenKey ?? "access_token";
|
|
39
|
-
console.log("keys test", tokenKey);
|
|
40
39
|
useEffect(() => {
|
|
41
40
|
configureTokenManager({ storage });
|
|
42
41
|
}, [storage]);
|
|
@@ -54,11 +53,9 @@ function createAuthContext(option) {
|
|
|
54
53
|
useEffect(() => {
|
|
55
54
|
const storedUser = manager.getSingleToken("user");
|
|
56
55
|
const token = manager.getSingleToken(tokenKey);
|
|
57
|
-
console.log("token review", token);
|
|
58
56
|
if (token && !manager.isExpired(token)) {
|
|
59
57
|
try {
|
|
60
58
|
setAuth(true);
|
|
61
|
-
console.log("authenticated", isAuthenticated);
|
|
62
59
|
if (storedUser) {
|
|
63
60
|
const parsedUser = JSON.parse(storedUser);
|
|
64
61
|
setUser(parsedUser);
|
package/package.json
CHANGED
package/src/AuthProvider.tsx
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use client'
|
|
2
2
|
|
|
3
|
-
import
|
|
3
|
+
import { createContext, useContext, ReactNode, useEffect } from 'react'
|
|
4
4
|
import { configureTokenManager, useTokenManager } from 'react-token-manager'
|
|
5
5
|
import { useAuthStore, User } from '../store/useGuardStore'
|
|
6
6
|
|
|
@@ -32,9 +32,6 @@ export function createAuthContext<UserType extends User = User>(option?: {
|
|
|
32
32
|
const storage = option?.storage ?? 'cookie'
|
|
33
33
|
const tokenKey = option?.tokenKey ?? 'access_token'
|
|
34
34
|
|
|
35
|
-
console.log('keys test', tokenKey);
|
|
36
|
-
|
|
37
|
-
|
|
38
35
|
useEffect(() => {
|
|
39
36
|
configureTokenManager({ storage })
|
|
40
37
|
}, [storage])
|
|
@@ -57,21 +54,16 @@ export function createAuthContext<UserType extends User = User>(option?: {
|
|
|
57
54
|
|
|
58
55
|
useEffect(() => {
|
|
59
56
|
const storedUser = manager.getSingleToken('user')
|
|
60
|
-
const token = manager.getSingleToken(tokenKey)
|
|
57
|
+
const token = manager.getSingleToken(tokenKey)
|
|
61
58
|
|
|
62
|
-
console.log('token review', token);
|
|
63
|
-
|
|
64
|
-
|
|
65
59
|
if (token && !manager.isExpired(token)) {
|
|
66
|
-
|
|
67
60
|
try {
|
|
68
61
|
setAuth(true)
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
if(storedUser) {
|
|
62
|
+
|
|
63
|
+
if (storedUser) {
|
|
72
64
|
const parsedUser = JSON.parse(storedUser) as UserType
|
|
73
65
|
setUser(parsedUser)
|
|
74
|
-
setRole((parsedUser as any)?.role ?? null)
|
|
66
|
+
setRole((parsedUser as any)?.role ?? null)
|
|
75
67
|
}
|
|
76
68
|
} catch {
|
|
77
69
|
resetAuth()
|
|
@@ -79,10 +71,10 @@ export function createAuthContext<UserType extends User = User>(option?: {
|
|
|
79
71
|
} else {
|
|
80
72
|
resetAuth()
|
|
81
73
|
}
|
|
82
|
-
|
|
74
|
+
|
|
83
75
|
setAuthChecked(true)
|
|
84
76
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
85
|
-
}, [tokenKey])
|
|
77
|
+
}, [tokenKey])
|
|
86
78
|
|
|
87
79
|
/* ---------------------------------- */
|
|
88
80
|
/* Login */
|