diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index c5de508..ecc11de 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -4,17 +4,10 @@
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
@@ -136,7 +129,7 @@
1774643312599
-
+
@@ -298,7 +291,15 @@
1774716452045
-
+
+
+ 1774717104130
+
+
+
+ 1774717104130
+
+
@@ -327,6 +328,7 @@
-
+
+
\ No newline at end of file
diff --git a/apps/api/prisma/seed.ts b/apps/api/prisma/seed.ts
index 3004f3c..1b52b98 100644
--- a/apps/api/prisma/seed.ts
+++ b/apps/api/prisma/seed.ts
@@ -7,13 +7,13 @@ async function main() {
const hashedPassword = await bcrypt.hash('admin123', 10);
const org = await prisma.organization.upsert({
- where: { id: 'test-org-id' },
+ where: { id: 'default-org-id' },
update: {
logoUrl: 'https://images.unsplash.com/photo-1542744173-8e7e53415bb0?q=80&w=200&h=200&auto=format&fit=crop',
},
create: {
- id: 'test-org-id',
- name: 'Test Organization',
+ id: 'default-org-id',
+ name: 'Default Organization',
logoUrl: 'https://images.unsplash.com/photo-1542744173-8e7e53415bb0?q=80&w=200&h=200&auto=format&fit=crop',
},
});
diff --git a/apps/api/src/prisma/prisma.module.ts b/apps/api/src/prisma/prisma.module.ts
index 7207426..fcedfc2 100644
--- a/apps/api/src/prisma/prisma.module.ts
+++ b/apps/api/src/prisma/prisma.module.ts
@@ -1,9 +1,10 @@
import { Global, Module } from '@nestjs/common';
import { PrismaService } from './prisma.service';
+import { SeedService } from './seed.service';
@Global()
@Module({
- providers: [PrismaService],
+ providers: [PrismaService, SeedService],
exports: [PrismaService],
})
export class PrismaModule {}
diff --git a/apps/api/src/prisma/seed.service.ts b/apps/api/src/prisma/seed.service.ts
new file mode 100644
index 0000000..cd67d92
--- /dev/null
+++ b/apps/api/src/prisma/seed.service.ts
@@ -0,0 +1,46 @@
+import { Injectable, OnModuleInit, Logger } from '@nestjs/common';
+import { PrismaService } from './prisma.service';
+import * as bcrypt from 'bcrypt';
+import { Role } from '@prisma/client';
+
+@Injectable()
+export class SeedService implements OnModuleInit {
+ private readonly logger = new Logger(SeedService.name);
+
+ constructor(private prisma: PrismaService) {}
+
+ async onModuleInit() {
+ await this.seed();
+ }
+
+ async seed() {
+ const userCount = await this.prisma.user.count();
+
+ if (userCount === 0) {
+ this.logger.log('No users found in database. Seeding default admin account...');
+
+ const hashedPassword = await bcrypt.hash('admin123', 10);
+
+ const org = await this.prisma.organization.upsert({
+ where: { id: 'default-org-id' },
+ update: {},
+ create: {
+ id: 'default-org-id',
+ name: 'Default Organization',
+ logoUrl: 'https://images.unsplash.com/photo-1542744173-8e7e53415bb0?q=80&w=200&h=200&auto=format&fit=crop',
+ },
+ });
+
+ await this.prisma.user.create({
+ data: {
+ email: 'admin@example.com',
+ password: hashedPassword,
+ role: Role.ADMIN,
+ organizationId: org.id,
+ },
+ });
+
+ this.logger.log('Default admin account created: admin@example.com / admin123');
+ }
+ }
+}
diff --git a/apps/web/src/routes/login/+page.svelte b/apps/web/src/routes/login/+page.svelte
index bbcd839..a4c2e68 100644
--- a/apps/web/src/routes/login/+page.svelte
+++ b/apps/web/src/routes/login/+page.svelte
@@ -74,10 +74,6 @@
-
-
Use seeded credentials:
-
admin@example.com / admin123
-
{/if}