MCPcopy Create free account
hub / github.com/error311/FileRise / fetchProfilePicture

Function fetchProfilePicture

public/js/auth.js:318–338  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

316}
317
318async function fetchProfilePicture() {
319 try {
320 const res = await fetch('/api/profile/getCurrentUser.php', {
321 credentials: 'include'
322 });
323 if (!res.ok) throw new Error(`HTTP ${res.status}`);
324 const info = await res.json();
325 let pic = info.profile_picture || '';
326 // --- take only what's after the *last* colon ---
327 const parts = pic.split(':');
328 pic = parts[parts.length - 1] || '';
329 // strip any stray leading colons
330 pic = pic.replace(/^:+/, '');
331 // ensure exactly one leading slash
332 if (pic) pic = '/' + pic.replace(/^\/+/, '');
333 return pic ? withBase(pic) : '';
334 } catch (e) {
335 console.warn('fetchProfilePicture failed:', e);
336 return '';
337 }
338}
339
340export async function updateAuthenticatedUI(data) {
341 // Save latest auth data for later reuse

Callers 1

updateAuthenticatedUIFunction · 0.85

Calls 2

withBaseFunction · 0.85
splitMethod · 0.80

Tested by

no test coverage detected