refactor(web): user-settings (#3700)

* refactor(web): user-settings

* feat: move the logic to the server

* use const

* fix: error 403

* fix: remove console.log
This commit is contained in:
martin
2023-08-17 05:56:06 +02:00
committed by GitHub
parent 53f5643994
commit 78a2a9e666
6 changed files with 22 additions and 26 deletions

View File

@@ -2,13 +2,21 @@ import { AppRoute } from '$lib/constants';
import { redirect } from '@sveltejs/kit';
import type { PageServerLoad } from './$types';
export const load = (async ({ locals: { user } }) => {
export const load = (async ({ parent, locals }) => {
const { user } = await parent();
if (!user) {
throw redirect(302, AppRoute.AUTH_LOGIN);
}
const { data: keys } = await locals.api.keyApi.getKeys();
const { data: devices } = await locals.api.authenticationApi.getAuthDevices();
const { data: partners } = await locals.api.partnerApi.getPartners({ direction: 'shared-by' });
return {
user,
keys,
devices,
partners,
meta: {
title: 'Settings',
},

View File

@@ -9,7 +9,7 @@
<UserPageLayout user={data.user} title={data.meta.title}>
<section class="mx-4 flex place-content-center">
<div class="w-full max-w-3xl">
<UserSettingsList user={data.user} />
<UserSettingsList user={data.user} keys={data.keys} devices={data.devices} partners={data.partners} />
</div>
</section>
</UserPageLayout>