@sparkstudio/authentication-ui 1.0.6 → 1.0.8
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.cjs +18 -1
- package/dist/index.d.cts +2 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +18 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -111,8 +111,10 @@ function UserProvider({
|
|
|
111
111
|
onLogoutFailed
|
|
112
112
|
}) {
|
|
113
113
|
const [user, setUserState] = (0, import_react.useState)(null);
|
|
114
|
+
const [isLoading, setIsLoading] = (0, import_react.useState)(true);
|
|
114
115
|
(0, import_react.useEffect)(() => {
|
|
115
116
|
const fetchUser = async () => {
|
|
117
|
+
setIsLoading(true);
|
|
116
118
|
try {
|
|
117
119
|
const api = new SparkStudioAuthenticationSDK(apiUrl);
|
|
118
120
|
const me = await api.auth.GetCurrentUser();
|
|
@@ -121,6 +123,8 @@ function UserProvider({
|
|
|
121
123
|
console.warn("No user logged in", error);
|
|
122
124
|
setUserState(null);
|
|
123
125
|
onLoginFailed?.(error);
|
|
126
|
+
} finally {
|
|
127
|
+
setIsLoading(false);
|
|
124
128
|
}
|
|
125
129
|
};
|
|
126
130
|
fetchUser();
|
|
@@ -145,7 +149,20 @@ function UserProvider({
|
|
|
145
149
|
}
|
|
146
150
|
setUserState(null);
|
|
147
151
|
};
|
|
148
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
152
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
153
|
+
UserContext.Provider,
|
|
154
|
+
{
|
|
155
|
+
value: {
|
|
156
|
+
user,
|
|
157
|
+
setUser,
|
|
158
|
+
logout,
|
|
159
|
+
apiUrl,
|
|
160
|
+
isAuthenticated: !!user,
|
|
161
|
+
isLoading
|
|
162
|
+
},
|
|
163
|
+
children
|
|
164
|
+
}
|
|
165
|
+
);
|
|
149
166
|
}
|
|
150
167
|
function useUser() {
|
|
151
168
|
const context = (0, import_react.useContext)(UserContext);
|
package/dist/index.d.cts
CHANGED
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -84,8 +84,10 @@ function UserProvider({
|
|
|
84
84
|
onLogoutFailed
|
|
85
85
|
}) {
|
|
86
86
|
const [user, setUserState] = useState(null);
|
|
87
|
+
const [isLoading, setIsLoading] = useState(true);
|
|
87
88
|
useEffect(() => {
|
|
88
89
|
const fetchUser = async () => {
|
|
90
|
+
setIsLoading(true);
|
|
89
91
|
try {
|
|
90
92
|
const api = new SparkStudioAuthenticationSDK(apiUrl);
|
|
91
93
|
const me = await api.auth.GetCurrentUser();
|
|
@@ -94,6 +96,8 @@ function UserProvider({
|
|
|
94
96
|
console.warn("No user logged in", error);
|
|
95
97
|
setUserState(null);
|
|
96
98
|
onLoginFailed?.(error);
|
|
99
|
+
} finally {
|
|
100
|
+
setIsLoading(false);
|
|
97
101
|
}
|
|
98
102
|
};
|
|
99
103
|
fetchUser();
|
|
@@ -118,7 +122,20 @@ function UserProvider({
|
|
|
118
122
|
}
|
|
119
123
|
setUserState(null);
|
|
120
124
|
};
|
|
121
|
-
return /* @__PURE__ */ jsx(
|
|
125
|
+
return /* @__PURE__ */ jsx(
|
|
126
|
+
UserContext.Provider,
|
|
127
|
+
{
|
|
128
|
+
value: {
|
|
129
|
+
user,
|
|
130
|
+
setUser,
|
|
131
|
+
logout,
|
|
132
|
+
apiUrl,
|
|
133
|
+
isAuthenticated: !!user,
|
|
134
|
+
isLoading
|
|
135
|
+
},
|
|
136
|
+
children
|
|
137
|
+
}
|
|
138
|
+
);
|
|
122
139
|
}
|
|
123
140
|
function useUser() {
|
|
124
141
|
const context = useContext(UserContext);
|