small fixes, cleanup and test out github actions

This commit is contained in:
d34dscene
2025-11-12 17:24:59 +01:00
parent 1454b0a15c
commit 8aac457cd8
96 changed files with 18730 additions and 16888 deletions

View File

@@ -12,45 +12,28 @@ export const trailingSlash = 'always';
export const load: LayoutLoad = async ({ url, fetch }) => {
const currentPath = url.pathname;
const isPublic = currentPath.startsWith('/login') || currentPath.startsWith('/welcome');
const isPublic = currentPath.startsWith('/login');
const healthy = await checkHealth(fetch);
if (!healthy) {
// No backend, force redirect to welcome screen to enter backend URL
if (currentPath !== '/welcome') {
await goto('/welcome');
user.clear();
return {};
}
} else {
// Backend reachable
if (currentPath === '/welcome') {
// Backend is back, redirect from welcome to login
await goto('/login');
return {};
try {
const userClient = useClient(UserService, fetch);
const resUser = await userClient.getUser({});
if (!resUser.user) throw new Error('Authentication failed');
user.value = resUser.user;
const profileClient = useClient(ProfileService, fetch);
if (!profile.id) {
const response = await profileClient.listProfiles({});
profile.value = response.profiles[0];
} else {
const response = await profileClient.getProfile({ id: profile.id });
if (!response.profile) throw new Error('Profile not found');
profile.value = response.profile;
}
try {
const userClient = useClient(UserService, fetch);
const resUser = await userClient.getUser({});
if (!resUser.user) throw new Error('Authentication failed');
user.value = resUser.user;
const profileClient = useClient(ProfileService, fetch);
if (!profile.id) {
const response = await profileClient.listProfiles({});
profile.value = response.profiles[0];
} else {
const response = await profileClient.getProfile({ id: profile.id });
if (!response.profile) throw new Error('Profile not found');
profile.value = response.profile;
}
if (isPublic) await goto('/');
} catch (_) {
user.clear();
profile.clear();
if (!isPublic) await goto('/login');
}
if (isPublic) await goto('/');
} catch (_) {
user.clear();
profile.clear();
if (!isPublic) await goto('/login');
}
};