@erikey/react 0.1.4 → 0.1.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 +7 -3
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +7 -3
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1972,19 +1972,23 @@ function createAuthClient3(config) {
|
|
|
1972
1972
|
},
|
|
1973
1973
|
getUser: async () => {
|
|
1974
1974
|
const result = await client.getUser();
|
|
1975
|
-
|
|
1975
|
+
const hasUser = result.success && result.data && ("email" in result.data || // Direct User object
|
|
1976
|
+
"user" in result.data && result.data.user);
|
|
1977
|
+
if (hasUser) {
|
|
1976
1978
|
return result;
|
|
1977
1979
|
}
|
|
1978
1980
|
const token = getStoredToken(projectId);
|
|
1979
1981
|
if (token) {
|
|
1980
|
-
|
|
1982
|
+
console.log("[Sandpack Auth] Cookie auth returned no user, trying Bearer token");
|
|
1983
|
+
const response = await fetch(`${baseUrl}/api/auth/get-session`, {
|
|
1981
1984
|
headers: {
|
|
1982
1985
|
"Authorization": `Bearer ${token}`,
|
|
1983
1986
|
"X-Project-Id": projectId
|
|
1984
1987
|
}
|
|
1985
1988
|
});
|
|
1986
1989
|
const data = await response.json();
|
|
1987
|
-
if (response.ok) {
|
|
1990
|
+
if (response.ok && (data?.user || data?.email)) {
|
|
1991
|
+
console.log("[Sandpack Auth] Bearer token auth successful");
|
|
1988
1992
|
return { success: true, data };
|
|
1989
1993
|
}
|
|
1990
1994
|
}
|