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:
1 parent
8c6ff77fac
commit
5651ad475d
83 files changed
+395
-469
No files matched your search
@@ -4,8 +4,8 @@ import { getClient } from '$lib/lemmy.js'
|
||||
import { site as siteStore } from '$lib/lemmy'
|
||||
|
||||
export async function load({ fetch }) {
|
||||
if (!get(profile)) return
|
||||
let { jwt } = get(profile)!
|
||||
if (!profile) return
|
||||
let { jwt } = profile!
|
||||
let site = get(siteStore)
|
||||
|
||||
if (!site) {
|
||||
|
||||
@@ -3,9 +3,9 @@ import { getClient } from '$lib/lemmy.js'
|
||||
import { get } from 'svelte/store'
|
||||
|
||||
export async function load({ data, fetch, url }) {
|
||||
if (!get(profile)) return
|
||||
if (!profile) return
|
||||
|
||||
const { jwt } = get(profile)!
|
||||
const { jwt } = profile.data!
|
||||
if (!jwt) return
|
||||
|
||||
const page = Number(url.searchParams.get('page')) || 1
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
let reviewing = $state(false)
|
||||
|
||||
async function review(approve: boolean) {
|
||||
if (!$profile?.jwt) return
|
||||
if (!profile.data?.jwt) return
|
||||
|
||||
let registrationApplicationAnswer: ApproveRegistrationApplication = {
|
||||
approve: approve,
|
||||
@@ -61,7 +61,7 @@
|
||||
type: 'success',
|
||||
})
|
||||
application.creator_local_user.accepted_application = approve
|
||||
application.admin = $profile.user!.local_user_view.person
|
||||
application.admin = profile.data.user!.local_user_view.person
|
||||
application.registration_application.deny_reason = denyReason
|
||||
|
||||
$notifications.applications -= 1
|
||||
|
||||
@@ -38,10 +38,10 @@
|
||||
)
|
||||
|
||||
async function save() {
|
||||
if (!$profile?.jwt) return
|
||||
if (!profile.data?.jwt) return
|
||||
|
||||
saving = true
|
||||
const { jwt } = $profile
|
||||
const { jwt } = profile.data
|
||||
|
||||
try {
|
||||
await getClient().editSite({
|
||||
@@ -242,8 +242,8 @@
|
||||
</Switch>
|
||||
|
||||
<div class="space-y-1">
|
||||
<SectionTitle>{$t('form.profile.languages.title')}</SectionTitle>
|
||||
<p>{$t('form.profile.languages.description')}</p>
|
||||
<SectionTitle>{$t('form.profile.data.languages.title')}</SectionTitle>
|
||||
<p>{$t('form.profile.data.languages.description')}</p>
|
||||
<Material rounding="xl" color="uniform" class="dark:bg-zinc-950">
|
||||
{#if $site && formData.discussion_languages}
|
||||
<div class="flex gap-2 flex-wrap flex-row">
|
||||
|
||||
@@ -46,7 +46,7 @@
|
||||
if (instance == '') return
|
||||
await trycatch(async () => {
|
||||
if (
|
||||
!$profile?.jwt ||
|
||||
!profile.data?.jwt ||
|
||||
!data.federated_instances?.federated_instances?.blocked ||
|
||||
!data.federated_instances?.federated_instances?.allowed
|
||||
)
|
||||
@@ -87,7 +87,7 @@
|
||||
const save = async () => {
|
||||
const res = await trycatch(async () => {
|
||||
if (
|
||||
!$profile?.jwt ||
|
||||
!profile.data?.jwt ||
|
||||
!data.federated_instances?.federated_instances?.blocked
|
||||
)
|
||||
return
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
let saving = $state(false)
|
||||
|
||||
async function save() {
|
||||
if (!$profile?.jwt) return
|
||||
if (!profile.data?.jwt) return
|
||||
|
||||
saving = true
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
action: () => removeAdmin(id, true),
|
||||
})
|
||||
|
||||
if (!$profile?.jwt) return
|
||||
if (!profile.data?.jwt) return
|
||||
|
||||
const result = await trycatch(() =>
|
||||
getClient().addAdmin({
|
||||
@@ -75,10 +75,14 @@
|
||||
class="flex flex-row items-center gap-2 mt-auto w-full"
|
||||
onsubmit={preventDefault(() => {
|
||||
trycatch(async () => {
|
||||
if (!$profile?.jwt || newAdmin == '') return
|
||||
if (!profile.data?.jwt || newAdmin == '') return
|
||||
adding = true
|
||||
|
||||
const r = await addAdmin(`${newAdmin}@${$instance}`, true, $profile.jwt)
|
||||
const r = await addAdmin(
|
||||
`${newAdmin}@${$instance}`,
|
||||
true,
|
||||
profile.data.jwt,
|
||||
)
|
||||
if (!r) return
|
||||
|
||||
toast({
|
||||
|
||||
Reference in new issue
Block a user