@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.js
CHANGED
|
@@ -1997,19 +1997,23 @@ function createAuthClient3(config) {
|
|
|
1997
1997
|
},
|
|
1998
1998
|
getUser: async () => {
|
|
1999
1999
|
const result = await client.getUser();
|
|
2000
|
-
|
|
2000
|
+
const hasUser = result.success && result.data && ("email" in result.data || // Direct User object
|
|
2001
|
+
"user" in result.data && result.data.user);
|
|
2002
|
+
if (hasUser) {
|
|
2001
2003
|
return result;
|
|
2002
2004
|
}
|
|
2003
2005
|
const token = getStoredToken(projectId);
|
|
2004
2006
|
if (token) {
|
|
2005
|
-
|
|
2007
|
+
console.log("[Sandpack Auth] Cookie auth returned no user, trying Bearer token");
|
|
2008
|
+
const response = await fetch(`${baseUrl}/api/auth/get-session`, {
|
|
2006
2009
|
headers: {
|
|
2007
2010
|
"Authorization": `Bearer ${token}`,
|
|
2008
2011
|
"X-Project-Id": projectId
|
|
2009
2012
|
}
|
|
2010
2013
|
});
|
|
2011
2014
|
const data = await response.json();
|
|
2012
|
-
if (response.ok) {
|
|
2015
|
+
if (response.ok && (data?.user || data?.email)) {
|
|
2016
|
+
console.log("[Sandpack Auth] Bearer token auth successful");
|
|
2013
2017
|
return { success: true, data };
|
|
2014
2018
|
}
|
|
2015
2019
|
}
|