Tenantdaten vollständig laden
Lädt den aktiven Tenant über die Tenant-Route nach und gibt calendarConfig in der Me-Antwort mit zurück.
This commit is contained in:
@@ -52,6 +52,7 @@ export default async function meRoutes(server: FastifyInstance) {
|
||||
id: tenants.id,
|
||||
name: tenants.name,
|
||||
short: tenants.short,
|
||||
calendarConfig: tenants.calendarConfig,
|
||||
hasActiveLicense: tenants.hasActiveLicense,
|
||||
locked: tenants.locked,
|
||||
features: tenants.features,
|
||||
|
||||
@@ -28,7 +28,21 @@ export default async function tenantRoutes(server: FastifyInstance) {
|
||||
// -------------------------------------------------------------
|
||||
// GET CURRENT TENANT
|
||||
// -------------------------------------------------------------
|
||||
server.get("/tenant", async (req) => {
|
||||
server.get("/tenant", async (req, reply) => {
|
||||
if (req.user?.tenant_id) {
|
||||
const tenantRows = await server.db
|
||||
.select()
|
||||
.from(tenants)
|
||||
.where(eq(tenants.id, Number(req.user.tenant_id)))
|
||||
.limit(1)
|
||||
|
||||
if (!tenantRows.length) {
|
||||
return reply.code(404).send({ error: "Tenant not found" })
|
||||
}
|
||||
|
||||
return tenantRows[0]
|
||||
}
|
||||
|
||||
if (req.tenant) {
|
||||
return {
|
||||
message: `Hallo vom Tenant ${req.tenant?.name}`,
|
||||
|
||||
Reference in New Issue
Block a user