mirror of
https://github.com/whoswhip/Sharpbin.git
synced 2026-12-06 02:48:43 +00:00
feat: guest param in user page
shows as if the user isnt logged in, except for the settings tab
This commit is contained in:
@@ -39,9 +39,10 @@ export const load: PageServerLoad = async ({ params, fetch, cookies, url, parent
|
|||||||
const { username } = params;
|
const { username } = params;
|
||||||
const { options } = await parent();
|
const { options } = await parent();
|
||||||
const jwtUuid = decodeJwtUuid(token);
|
const jwtUuid = decodeJwtUuid(token);
|
||||||
|
const asGuest = url.searchParams.get('guest') === '1';
|
||||||
|
|
||||||
const res = await fetch(`${apiUrl}/api/user/${username}`, {
|
const res = await fetch(`${apiUrl}/api/user/${username}`, {
|
||||||
headers: token ? { Authorization: `Bearer ${token}` } : undefined
|
headers: token && !asGuest ? { Authorization: `Bearer ${token}` } : undefined
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!res.ok) {
|
if (!res.ok) {
|
||||||
@@ -70,14 +71,14 @@ export const load: PageServerLoad = async ({ params, fetch, cookies, url, parent
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
if (token && canModerate && (!reportsSubmitted || !isOwner)) {
|
if (token && !asGuest && canModerate && (!reportsSubmitted || !isOwner)) {
|
||||||
const submittedRes = await fetch(`${apiUrl}/api/user/${user.uuid}/reports/submitted`, {
|
const submittedRes = await fetch(`${apiUrl}/api/user/${user.uuid}/reports/submitted`, {
|
||||||
headers: { Authorization: `Bearer ${token}` }
|
headers: { Authorization: `Bearer ${token}` }
|
||||||
});
|
});
|
||||||
if (submittedRes.ok) reportsSubmitted = await submittedRes.json();
|
if (submittedRes.ok) reportsSubmitted = await submittedRes.json();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (token && !isOwner) {
|
if (token && !asGuest && !isOwner) {
|
||||||
if (canModerate) {
|
if (canModerate) {
|
||||||
const r = await fetch(`${apiUrl}/api/user/${user.uuid}/reports`, {
|
const r = await fetch(`${apiUrl}/api/user/${user.uuid}/reports`, {
|
||||||
headers: { Authorization: `Bearer ${token}` }
|
headers: { Authorization: `Bearer ${token}` }
|
||||||
|
|||||||
Reference in New Issue
Block a user