@erikey/react 0.1.6 → 0.1.7
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 +3 -9
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +3 -9
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1983,15 +1983,8 @@ function createAuthClient3(config) {
|
|
|
1983
1983
|
return result;
|
|
1984
1984
|
},
|
|
1985
1985
|
getUser: async () => {
|
|
1986
|
-
const result = await client.getUser();
|
|
1987
|
-
const hasUser = result.success && result.data && ("email" in result.data || // Direct User object
|
|
1988
|
-
"user" in result.data && result.data.user);
|
|
1989
|
-
if (hasUser) {
|
|
1990
|
-
return result;
|
|
1991
|
-
}
|
|
1992
1986
|
const token = getStoredToken(projectId);
|
|
1993
1987
|
if (token) {
|
|
1994
|
-
console.log("[Sandpack Auth] Cookie auth returned no user, trying Bearer token");
|
|
1995
1988
|
const response = await fetch(`${baseUrl}/api/auth/get-session`, {
|
|
1996
1989
|
headers: {
|
|
1997
1990
|
"Authorization": `Bearer ${token}`,
|
|
@@ -2000,11 +1993,12 @@ function createAuthClient3(config) {
|
|
|
2000
1993
|
});
|
|
2001
1994
|
const data = await response.json();
|
|
2002
1995
|
if (response.ok && (data?.user || data?.email)) {
|
|
2003
|
-
console.log("[Sandpack Auth] Bearer token auth successful");
|
|
2004
1996
|
return { success: true, data };
|
|
2005
1997
|
}
|
|
1998
|
+
console.log("[Sandpack Auth] Bearer token invalid, clearing");
|
|
1999
|
+
clearToken(projectId);
|
|
2006
2000
|
}
|
|
2007
|
-
return
|
|
2001
|
+
return { success: true, data: void 0 };
|
|
2008
2002
|
},
|
|
2009
2003
|
forgotPassword: client.forgotPassword,
|
|
2010
2004
|
resetPassword: client.resetPassword,
|