varminer-app-header 2.1.9 → 2.2.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 CHANGED
@@ -376,32 +376,17 @@ const getAllDataFromStorage = () => {
376
376
  }
377
377
  };
378
378
  /**
379
- * Get profile picture URL from object store API using tenant_id and user_id from JWT token
379
+ * Get profile picture URL from object store API using user_id.
380
380
  * @param baseUrl - Base URL for the object store API (default: http://objectstore.impact0mics.local:9012)
381
- * @returns Profile picture URL or null if tenant_id or user_id is not available
381
+ * @returns Profile picture URL or null if user_id is not available
382
382
  */
383
383
  const getProfilePictureUrl = (baseUrl = "http://objectstore.impact0mics.local:9012") => {
384
384
  try {
385
385
  const allData = getAllDataFromStorage();
386
- // Get tenant_id and user_id from decoded token
387
- let tenantId = null;
388
- let userId = null;
389
- if (allData.decodedToken) {
390
- tenantId = allData.decodedToken.tenant_id || allData.decodedToken.tenant || null;
391
- userId = allData.decodedToken.user_id || null;
392
- }
393
- // If not found in decoded token, try auth data
394
- if ((!tenantId || !userId) && allData.auth) {
395
- tenantId = tenantId || allData.auth.tenant_id || allData.auth.tenant || null;
396
- userId = userId || allData.auth.user_id || null;
397
- }
398
- // Construct URL if we have both tenant_id and user_id
399
- if (tenantId && userId) {
400
- // Remove trailing slash from baseUrl if present
401
- const cleanBaseUrl = baseUrl.replace(/\/$/, '');
402
- return `${cleanBaseUrl}/v1/objectStore/profilePicture/path/${tenantId}/${userId}`;
403
- }
404
- return null;
386
+ const userId = allData.decodedToken?.user_id ?? allData.auth?.user_id ?? getStoredUserDetails()?.userId ?? null;
387
+ if (userId == null)
388
+ return null;
389
+ return `${baseUrl.replace(/\/$/, "")}/v1/objectStore/profilePicture/path/${userId}`;
405
390
  }
406
391
  catch (err) {
407
392
  console.error("Error getting profile picture URL:", err);