@sanvika/auth 2.0.0 → 2.1.0
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 +14 -3
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -51,6 +51,12 @@ function SanvikaAuthProvider({ children }) {
|
|
|
51
51
|
setUser(data.user);
|
|
52
52
|
return data;
|
|
53
53
|
};
|
|
54
|
+
const setAuth = (token, userData) => {
|
|
55
|
+
localStorage.setItem(STORAGE_KEYS.ACCESS_TOKEN, token);
|
|
56
|
+
localStorage.setItem(STORAGE_KEYS.USER, JSON.stringify(userData));
|
|
57
|
+
setToken(token);
|
|
58
|
+
setUser(userData);
|
|
59
|
+
};
|
|
54
60
|
const logout = async () => {
|
|
55
61
|
try {
|
|
56
62
|
await fetch(`${SA_URL}/api/auth/logout`, {
|
|
@@ -75,7 +81,8 @@ function SanvikaAuthProvider({ children }) {
|
|
|
75
81
|
loading,
|
|
76
82
|
isAuthenticated: !!user,
|
|
77
83
|
login,
|
|
78
|
-
logout
|
|
84
|
+
logout,
|
|
85
|
+
setAuth
|
|
79
86
|
};
|
|
80
87
|
return /* @__PURE__ */ jsx(SanvikaAuthContext.Provider, { value, children });
|
|
81
88
|
}
|
|
@@ -264,11 +271,15 @@ function SanvikaAccountButtonContent({
|
|
|
264
271
|
"button",
|
|
265
272
|
{
|
|
266
273
|
className: `snvk-guestBtn ${className}`,
|
|
267
|
-
onClick: () => {
|
|
274
|
+
onClick: (e) => {
|
|
275
|
+
console.log("[SanvikaAccountButton] \u2705\u2705\u2705 BUTTON CLICKED!");
|
|
276
|
+
console.log("[SanvikaAccountButton] Event target:", e.target);
|
|
268
277
|
if (onLoginClick) {
|
|
278
|
+
console.log("[SanvikaAccountButton] Calling custom onLoginClick");
|
|
269
279
|
onLoginClick();
|
|
270
280
|
} else {
|
|
271
|
-
|
|
281
|
+
console.log("[SanvikaAccountButton] Redirecting to /authorize...");
|
|
282
|
+
window.location.href = "/authorize";
|
|
272
283
|
}
|
|
273
284
|
},
|
|
274
285
|
"aria-label": "Login or Sign Up",
|