🚀 Phase 3 Complete: Fix staff list, PDF preview, and functional Settings/Profile
This commit is contained in:
@@ -46,4 +46,9 @@ export class UsersController {
|
||||
async remove(@CurrentUser() user: any, @Param('id') id: string) {
|
||||
return this.usersService.remove(user.tenantId, id, user.id);
|
||||
}
|
||||
|
||||
@Post('profile')
|
||||
async updateProfile(@CurrentUser() user: any, @Body() dto: any) {
|
||||
return this.usersService.update(user.id, dto);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -71,4 +71,21 @@ export class UsersService {
|
||||
const user = await this.findOne(tenantId, id);
|
||||
await this.userRepository.update(id, { is_active: false });
|
||||
}
|
||||
|
||||
/**
|
||||
* تحديث بيانات مستخدم
|
||||
*/
|
||||
async update(id: string, dto: any): Promise<User> {
|
||||
const user = await this.userRepository.findOne({ where: { id } });
|
||||
if (!user) throw new NotFoundException('User not found');
|
||||
|
||||
// Hash password if provided
|
||||
if (dto.password) {
|
||||
dto.password_hash = await bcrypt.hash(dto.password, 12);
|
||||
delete dto.password;
|
||||
}
|
||||
|
||||
Object.assign(user, dto);
|
||||
return this.userRepository.save(user);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user