Allow profiles and license keys without a user; link them on registration

Admins can now create a Profile or License Key for someone who hasn't
registered yet (matched by email). When that person registers, any
unattached profile and license keys are linked to their new account.

Also remove the Proclamations surface from the user dashboard.
This commit is contained in:
NeilClack
2026-08-27 12:04:09 -05:00
parent b76a540dc4
commit 4373458272
9 changed files with 126 additions and 78 deletions
+2 -2
View File
@@ -9,12 +9,12 @@ export const load: LayoutServerLoad = async ({ locals, url }) => {
const user = await prisma.user.findUnique({
where: { id: locals.user.id },
select: { id: true, roleId: true, profile: { select: { id: true } } }
select: { id: true, roleId: true, profiles: { select: { id: true } } }
});
if (!user) {
throw error(403, 'not authorized');
}
if (!user.profile && !url.pathname.startsWith('/account/setup')) {
if (user.profiles.length === 0 && !url.pathname.startsWith('/account/setup')) {
// Skip redirect when already on /account/setup to avoid redirect loop
throw redirect(303, '/account/setup');
}