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:
@@ -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');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user