3.0.0 #220

Merged
flfeders merged 676 commits from dev into main 2026-09-20 16:10:48 +00:00
3 changed files with 37 additions and 0 deletions
Showing only changes of commit 1c68e6b724 - Show all commits

View File

@@ -246,6 +246,7 @@ export default async function adminRoutes(server: FastifyInstance) {
const [currentUser] = await server.db
.select({
id: authUsers.id,
email: authUsers.email,
is_admin: authUsers.is_admin,
})
.from(authUsers)
@@ -971,6 +972,38 @@ export default async function adminRoutes(server: FastifyInstance) {
const exportData = req.body as TenantFullExport;
const result = await importTenantFullExport(server, exportData);
const fallbackName = deriveNameFromEmail(currentUser.email);
await server.db
.insert(authTenantUsers)
.values({
tenant_id: result.tenantId,
user_id: currentUser.id,
created_by: currentUser.id,
})
.onConflictDoNothing();
const [existingAdminProfile] = await server.db
.select({ id: authProfiles.id })
.from(authProfiles)
.where(and(
eq(authProfiles.tenant_id, result.tenantId),
eq(authProfiles.user_id, currentUser.id)
))
.limit(1);
if (!existingAdminProfile) {
await server.db
.insert(authProfiles)
.values({
tenant_id: result.tenantId,
user_id: currentUser.id,
first_name: fallbackName.first_name,
last_name: fallbackName.last_name,
email: currentUser.email,
active: true,
});
}
return {
success: true,

View File

@@ -152,6 +152,8 @@ const importTenantExport = async (event: Event) => {
}
await fetchTenant()
await auth.fetchMe()
await auth.switchTenant(String(result.tenantId))
toast.add({
title: "Mandantenimport abgeschlossen",

View File

@@ -108,6 +108,7 @@ const importTenantExport = async (event: Event) => {
const rowCount = (result.tables || []).reduce((sum, table) => sum + table.rows, 0)
await fetchTenants()
await auth.fetchMe()
toast.add({
title: "Mandantenimport abgeschlossen",
@@ -116,6 +117,7 @@ const importTenantExport = async (event: Event) => {
})
if (result.tenantId) {
await auth.switchTenant(String(result.tenantId))
await router.push(`/administration/tenants/${result.tenantId}`)
}
} catch (err: any) {