@sanvika/auth 2.2.0 → 2.2.1
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 +4 -25
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -12,7 +12,7 @@ var DEFAULT_AVATAR_SVG = `data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/200
|
|
|
12
12
|
|
|
13
13
|
// SanvikaAuthProvider.jsx
|
|
14
14
|
import { jsx } from "react/jsx-runtime";
|
|
15
|
-
var
|
|
15
|
+
var S_AUTH_URL = "https://accounts.sanvikaproduction.com";
|
|
16
16
|
var SanvikaAuthContext = createContext(null);
|
|
17
17
|
function SanvikaAuthProvider({
|
|
18
18
|
children,
|
|
@@ -21,7 +21,7 @@ function SanvikaAuthProvider({
|
|
|
21
21
|
saUrl: saUrlProp,
|
|
22
22
|
dashboardPath
|
|
23
23
|
}) {
|
|
24
|
-
const saBaseUrl = saUrlProp ||
|
|
24
|
+
const saBaseUrl = saUrlProp || S_AUTH_URL;
|
|
25
25
|
const [user, setUser] = useState(null);
|
|
26
26
|
const [accessToken, setToken] = useState(null);
|
|
27
27
|
const [loading, setLoading] = useState(true);
|
|
@@ -40,7 +40,7 @@ function SanvikaAuthProvider({
|
|
|
40
40
|
}
|
|
41
41
|
}, []);
|
|
42
42
|
const login = async ({ mobile, password, deviceId, deviceName }) => {
|
|
43
|
-
const response = await fetch(`${
|
|
43
|
+
const response = await fetch(`${S_AUTH_URL}/api/auth/login`, {
|
|
44
44
|
method: "POST",
|
|
45
45
|
headers: { "Content-Type": "application/json" },
|
|
46
46
|
body: JSON.stringify({
|
|
@@ -66,7 +66,7 @@ function SanvikaAuthProvider({
|
|
|
66
66
|
};
|
|
67
67
|
const logout = async () => {
|
|
68
68
|
try {
|
|
69
|
-
await fetch(`${
|
|
69
|
+
await fetch(`${S_AUTH_URL}/api/auth/logout`, {
|
|
70
70
|
method: "POST",
|
|
71
71
|
headers: {
|
|
72
72
|
"Content-Type": "application/json",
|
|
@@ -216,9 +216,6 @@ function SanvikaAccountButtonContent({
|
|
|
216
216
|
}) {
|
|
217
217
|
var _a, _b;
|
|
218
218
|
const auth = useSanvikaAuth();
|
|
219
|
-
console.log("[SanvikaAccountButton] auth context:", auth);
|
|
220
|
-
console.log("[SanvikaAccountButton] auth type:", typeof auth);
|
|
221
|
-
console.log("[SanvikaAccountButton] auth is null:", auth === null);
|
|
222
219
|
const [dropdownOpen, setDropdownOpen] = useState2(false);
|
|
223
220
|
const [imgError, setImgError] = useState2(false);
|
|
224
221
|
const [prevImage, setPrevImage] = useState2((_a = auth == null ? void 0 : auth.user) == null ? void 0 : _a.image);
|
|
@@ -234,25 +231,14 @@ function SanvikaAccountButtonContent({
|
|
|
234
231
|
return () => document.removeEventListener("mousedown", handleOutside);
|
|
235
232
|
}, [dropdownOpen]);
|
|
236
233
|
if (!auth) {
|
|
237
|
-
console.log("[SanvikaAccountButton] Auth is null, showing guest button");
|
|
238
234
|
return /* @__PURE__ */ jsxs(
|
|
239
235
|
"button",
|
|
240
236
|
{
|
|
241
237
|
className: `snvk-guestBtn ${className}`,
|
|
242
238
|
onClick: (e) => {
|
|
243
|
-
console.log("[SanvikaAccountButton] \u2705\u2705\u2705 BUTTON CLICKED!");
|
|
244
|
-
console.log("[SanvikaAccountButton] Event target:", e.target);
|
|
245
|
-
console.log(
|
|
246
|
-
"[SanvikaAccountButton] Current URL:",
|
|
247
|
-
window.location.href
|
|
248
|
-
);
|
|
249
239
|
if (onLoginClick) {
|
|
250
|
-
console.log("[SanvikaAccountButton] Calling custom onLoginClick");
|
|
251
240
|
onLoginClick();
|
|
252
241
|
} else {
|
|
253
|
-
console.log(
|
|
254
|
-
"[SanvikaAccountButton] Redirecting to SA authorize..."
|
|
255
|
-
);
|
|
256
242
|
window.location.href = "https://accounts.sanvikaproduction.com/authorize";
|
|
257
243
|
}
|
|
258
244
|
},
|
|
@@ -283,16 +269,9 @@ function SanvikaAccountButtonContent({
|
|
|
283
269
|
{
|
|
284
270
|
className: `snvk-guestBtn ${className}`,
|
|
285
271
|
onClick: (e) => {
|
|
286
|
-
console.log("[SanvikaAccountButton] \u2705\u2705\u2705 BUTTON CLICKED!");
|
|
287
|
-
console.log("[SanvikaAccountButton] Event target:", e.target);
|
|
288
272
|
if (onLoginClick) {
|
|
289
|
-
console.log("[SanvikaAccountButton] Calling custom onLoginClick");
|
|
290
273
|
onLoginClick();
|
|
291
274
|
} else {
|
|
292
|
-
console.log(
|
|
293
|
-
"[SanvikaAccountButton] Redirecting to SA authorize...",
|
|
294
|
-
authorizeUrl
|
|
295
|
-
);
|
|
296
275
|
window.location.href = authorizeUrl;
|
|
297
276
|
}
|
|
298
277
|
},
|