feat: use state based auth instead of store based (#488)

* misc: switch to state for auth

* fix: class based auth not working
This commit is contained in:
Xylight authored and GitHub committed 2025-02-08 13:49:09 -08:00
1 parent 8c6ff77fac
commit 5651ad475d
83 files changed
+395 -469

No files matched your search

+7 -7
View File
@@ -77,7 +77,7 @@
style="border-radius: inherit;"
>
<div class="ml-auto"></div>
{#if $profile?.user && isAdmin($profile.user)}
{#if profile.data?.user && isAdmin(profile.data.user)}
<NavButton
href="/admin"
label={$t('nav.admin')}
@@ -92,7 +92,7 @@
{/if}
</NavButton>
{/if}
{#if amModOfAny($profile?.user)}
{#if amModOfAny(profile.data?.user)}
<NavButton
href="/moderation"
label={$t('nav.moderation')}
@@ -124,7 +124,7 @@
/>
{/snippet}
<MenuDivider>{$t('nav.create.label')}</MenuDivider>
<MenuButton link href="/create/post" disabled={!$profile?.jwt}>
<MenuButton link href="/create/post" disabled={!profile.data?.jwt}>
{#snippet prefix()}
<Icon src={PencilSquare} size="16" micro />
{/snippet}
@@ -133,17 +133,17 @@
<MenuButton
link
href="/create/community"
disabled={!$profile?.jwt ||
!$profile?.user ||
disabled={!profile.data?.jwt ||
!profile.data?.user ||
($site?.site_view.local_site.community_creation_admin_only &&
!isAdmin($profile.user))}
!isAdmin(profile.data.user))}
>
{#snippet prefix()}
<Icon src={Newspaper} size="16" micro />
{/snippet}
{$t('nav.create.community')}
</MenuButton>
{#if !$profile?.jwt}
{#if !profile.data?.jwt}
<span class="text-sm mx-4 my-1 py-1">
{$t('nav.create.logingate')}
</span>
+6 -6
View File
@@ -74,14 +74,14 @@
hover:border-primary-900 hover:dark:border-primary-100 active:scale-95 {buttonClass}"
title={$t('profile.profile')}
>
{#if $profile?.user}
{#if profile.data?.user}
<div
class="w-full h-full aspect-square object-cover rounded-full grid place-items-center"
>
<Avatar
url={$profile.user.local_user_view.person.avatar}
url={profile.data.user.local_user_view.person.avatar}
width={36}
alt={$profile.user.local_user_view.person.name}
alt={profile.data.user.local_user_view.person.name}
/>
</div>
{#if $notifications.inbox > 0}
@@ -96,9 +96,9 @@
{/if}
</button>
{/snippet}
{#if $profile?.user}
{#if profile.data?.user}
<UserLink
user={$profile?.user.local_user_view.person}
user={profile.data?.user.local_user_view.person}
showInstance={false}
avatar
avatarSize={24}
@@ -108,7 +108,7 @@
{:else}
<MenuDivider>{$t('nav.menu.label')}</MenuDivider>
{/if}
{#if $profile?.jwt}
{#if profile.data?.jwt}
<MenuButton link href="/profile">
{#snippet prefix()}
<Icon src={UserCircle} micro width={16} />
@@ -23,7 +23,6 @@
<Button
href={action.href}
onclick
alignment="left"
color="tertiary"
size="lg"
@@ -229,8 +229,8 @@
$effect(() => {
groups = getGroups(
$resumables,
$profile,
$profileData.profiles,
profile.data,
profileData.profiles,
$themeData,
page.data.contextual?.actions,
)
@@ -92,7 +92,7 @@ export function getGroups(
name: t.get('nav.communities'),
icon: GlobeAlt,
},
...(amModOfAny(profile.user)
...(amModOfAny(profile.data.user)
? [
{
href: '/moderation',
@@ -101,7 +101,7 @@ export function getGroups(
},
]
: []),
...(profile.user && isAdmin(profile.user)
...(profile.data.user && isAdmin(profile.data.user)
? [
{
href: '/admin',
@@ -236,23 +236,23 @@ export function getGroups(
],
},
{
name: t.get('profile.profile'),
actions: profile.jwt
name: t.get('profile.data.profile'),
actions: profile.data.jwt
? [
{
href: '/profile/user',
name: t.get('profile.profile'),
name: t.get('profile.data.profile'),
icon: UserCircle,
},
{
href: '/inbox',
name: t.get('profile.inbox'),
name: t.get('profile.data.inbox'),
icon: Inbox,
shortcut: 'i',
},
{
href: '/saved',
name: t.get('profile.saved'),
name: t.get('profile.data.saved'),
icon: Bookmark,
},
{
@@ -311,7 +311,7 @@ export function getGroups(
icon: p.avatar ?? UserCircle,
detail: p.instance,
handle: async () => {
if (profile.id != p.id) {
if (profile.data.id != p.id) {
await setUserID(p.id)
}
@@ -407,9 +407,9 @@ export function getGroups(
],
},
{
name: t.get('profile.subscribed'),
name: t.get('profile.data.subscribed'),
actions:
profile?.user?.follows.map((f) => ({
profile.data?.user?.follows.map((f) => ({
icon: f.community.icon,
name: f.community.title,
href: `/c/${fullCommunityName(