fix(web): sharing of access token in server API (#1858)

This commit is contained in:
Michel Heusschen
2023-02-24 21:42:20 +01:00
committed by GitHub
parent 3ea107be5a
commit cc6253ba38
14 changed files with 43 additions and 58 deletions

View File

@@ -0,0 +1,23 @@
export const prerender = false;
import { redirect } from '@sveltejs/kit';
import type { PageServerLoad } from './$types';
export const load = (async ({ locals: { api } }) => {
try {
const { data: userInfo } = await api.userApi.getMyUserInfo();
if (userInfo.shouldChangePassword) {
return {
user: userInfo,
meta: {
title: 'Change Password'
}
};
} else {
throw redirect(302, '/photos');
}
} catch (e) {
throw redirect(302, '/auth/login');
}
}) satisfies PageServerLoad;