refactor: nambahin role mentor di admin account dan ngeremove max_member di project
This commit is contained in:
@@ -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') {
|
||||
|
||||
Reference in New Issue
Block a user