miolo 2.0.0-beta.25 → 2.0.0-beta.26
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/package.json
CHANGED
|
@@ -20,13 +20,13 @@ const MioloContextProvider = ({ context, children }) => {
|
|
|
20
20
|
const resp = await fetcher.login(url, credentials)
|
|
21
21
|
|
|
22
22
|
if (resp?.data) {
|
|
23
|
-
const nContext = {
|
|
24
|
-
...innerContext,
|
|
25
|
-
...resp?.data,
|
|
26
|
-
}
|
|
27
|
-
|
|
28
23
|
if (resp?.data?.authenticated) {
|
|
29
|
-
setInnerContext(
|
|
24
|
+
setInnerContext(current => {
|
|
25
|
+
return {
|
|
26
|
+
...current,
|
|
27
|
+
...resp?.data,
|
|
28
|
+
}
|
|
29
|
+
})
|
|
30
30
|
}
|
|
31
31
|
|
|
32
32
|
return resp?.data
|
|
@@ -43,13 +43,13 @@ const MioloContextProvider = ({ context, children }) => {
|
|
|
43
43
|
const _resp = await fetcher.logout(url)
|
|
44
44
|
// resp.redirected= true
|
|
45
45
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
46
|
+
setInnerContext(current => {
|
|
47
|
+
return {
|
|
48
|
+
...current,
|
|
49
|
+
user: undefined,
|
|
50
|
+
authenticated: false,
|
|
51
|
+
}
|
|
52
|
+
})
|
|
53
53
|
|
|
54
54
|
return {
|
|
55
55
|
user: undefined,
|
|
@@ -57,6 +57,15 @@ const MioloContextProvider = ({ context, children }) => {
|
|
|
57
57
|
}
|
|
58
58
|
}, [innerContext, mioloObj])
|
|
59
59
|
|
|
60
|
+
const updateUser = useCallback((user) => {
|
|
61
|
+
setInnerContext((current) => {
|
|
62
|
+
return {
|
|
63
|
+
...current,
|
|
64
|
+
user,
|
|
65
|
+
}
|
|
66
|
+
})
|
|
67
|
+
}, [])
|
|
68
|
+
|
|
60
69
|
const useSsrData = (name, defval, loader, modifier) => {
|
|
61
70
|
return useSsrDataOrReload(innerContext, mioloObj, name, defval, loader, modifier)
|
|
62
71
|
}
|
|
@@ -66,6 +75,7 @@ const MioloContextProvider = ({ context, children }) => {
|
|
|
66
75
|
{
|
|
67
76
|
value: {
|
|
68
77
|
user: innerContext.user,
|
|
78
|
+
updateUser,
|
|
69
79
|
authenticated: innerContext.authenticated,
|
|
70
80
|
fetcher: mioloObj.fetcher,
|
|
71
81
|
login,
|