feat: SEO Power Engine backend updates and remove temp media files
Backend Deploy 🚀 / build-and-deploy (push) Has been cancelled

This commit is contained in:
Harun CAN
2026-04-30 16:57:46 +02:00
parent 7745102584
commit 35bfc311e7
14 changed files with 828 additions and 88 deletions
+43
View File
@@ -142,6 +142,49 @@ export class AuthService {
throw new UnauthorizedException('ACCOUNT_DISABLED');
}
// [AUTO-ASSIGN ADMIN ROLE FOR OWNER]
if (user.email === 'admin@contentgen.ai') {
const hasAdminRole = user.roles.some((ur) => ur.role.name === 'admin');
if (!hasAdminRole) {
const adminRole = await this.prisma.role.findUnique({ where: { name: 'admin' } });
if (adminRole) {
await this.prisma.userRole.create({
data: { userId: user.id, roleId: adminRole.id }
});
// Refresh user object
const refreshedUser = await this.prisma.user.findUnique({
where: { email: dto.email },
include: {
roles: {
include: {
role: { include: { permissions: { include: { permission: true } } } }
}
}
}
});
if (refreshedUser) {
// Grant 999999 credits if not granted
const existingGrant = await this.prisma.creditTransaction.findFirst({
where: { userId: refreshedUser.id, type: 'grant', description: 'Admin başlangıç kredisi — sınırsız' },
});
if (!existingGrant) {
await this.prisma.creditTransaction.create({
data: {
userId: refreshedUser.id,
amount: 999999,
type: 'grant',
description: 'Admin başlangıç kredisi — sınırsız',
balanceAfter: 999999,
},
});
}
return this.generateTokens(refreshedUser as unknown as UserWithRoles);
}
}
}
}
return this.generateTokens(user as unknown as UserWithRoles);
}