refactor: nambahin role mentor di admin account dan ngeremove max_member di project

This commit is contained in:
Rafi Athallah
2026-06-14 20:26:53 +07:00
parent edc287968d
commit 94bbc18224
10 changed files with 937 additions and 381 deletions
+5 -5
View File
@@ -86,7 +86,7 @@ class AuthService {
async getCurrentUser(userId, role) {
try {
if (role === 'admin') {
if (role === 'admin' || role === 'mentor') {
const result = await adminService.getAdminById(userId);
if (result.err) {
@@ -97,7 +97,7 @@ class AuthService {
return data({
...adminWithoutPassword,
role: 'admin'
role: adminWithoutPassword.role
});
} else if (role === 'intern') {
const user = await prisma.user.findUnique({
@@ -151,7 +151,7 @@ class AuthService {
const existingAdmin = await prisma.admin.findUnique({
where: { email }
});
if (existingAdmin && (role !== 'admin' || existingAdmin.id !== parseInt(userId))) {
if (existingAdmin && ((role !== 'admin' && role !== 'mentor') || existingAdmin.id !== parseInt(userId))) {
if (imageFile?.filename) {
const { deleteFileIfExists } = require('../../../helpers/utils/fileHelper');
await deleteFileIfExists(imageFile.filename).catch(() => { });
@@ -176,7 +176,7 @@ class AuthService {
hashedPassword = await bcrypt.hash(password, 10);
}
if (role === 'admin') {
if (role === 'admin' || role === 'mentor') {
const adminId = parseInt(userId);
const existingAdmin = await prisma.admin.findUnique({
where: { id: adminId }
@@ -220,7 +220,7 @@ class AuthService {
const { password: _, ...adminWithoutPassword } = updatedAdmin;
return data({
...adminWithoutPassword,
role: 'admin'
role: adminWithoutPassword.role
});
} else if (role === 'intern') {