@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.js
CHANGED
|
@@ -2008,15 +2008,8 @@ function createAuthClient3(config) {
|
|
|
2008
2008
|
return result;
|
|
2009
2009
|
},
|
|
2010
2010
|
getUser: async () => {
|
|
2011
|
-
const result = await client.getUser();
|
|
2012
|
-
const hasUser = result.success && result.data && ("email" in result.data || // Direct User object
|
|
2013
|
-
"user" in result.data && result.data.user);
|
|
2014
|
-
if (hasUser) {
|
|
2015
|
-
return result;
|
|
2016
|
-
}
|
|
2017
2011
|
const token = getStoredToken(projectId);
|
|
2018
2012
|
if (token) {
|
|
2019
|
-
console.log("[Sandpack Auth] Cookie auth returned no user, trying Bearer token");
|
|
2020
2013
|
const response = await fetch(`${baseUrl}/api/auth/get-session`, {
|
|
2021
2014
|
headers: {
|
|
2022
2015
|
"Authorization": `Bearer ${token}`,
|
|
@@ -2025,11 +2018,12 @@ function createAuthClient3(config) {
|
|
|
2025
2018
|
});
|
|
2026
2019
|
const data = await response.json();
|
|
2027
2020
|
if (response.ok && (data?.user || data?.email)) {
|
|
2028
|
-
console.log("[Sandpack Auth] Bearer token auth successful");
|
|
2029
2021
|
return { success: true, data };
|
|
2030
2022
|
}
|
|
2023
|
+
console.log("[Sandpack Auth] Bearer token invalid, clearing");
|
|
2024
|
+
clearToken(projectId);
|
|
2031
2025
|
}
|
|
2032
|
-
return
|
|
2026
|
+
return { success: true, data: void 0 };
|
|
2033
2027
|
},
|
|
2034
2028
|
forgotPassword: client.forgotPassword,
|
|
2035
2029
|
resetPassword: client.resetPassword,
|