"activate user admin"
This commit is contained in:
@@ -345,5 +345,25 @@ export class UserRepository implements IUserRepository {
|
||||
}
|
||||
}
|
||||
|
||||
async activate(id: string) {
|
||||
const startTime = Date.now();
|
||||
try {
|
||||
await this.repo.update(id, { state: UserState.VERIFIED_REGULAR });
|
||||
const result = await this.findById(id);
|
||||
logDatabase('User activated successfully', `update(${id}, { state: VERIFIED_REGULAR })`, Date.now() - startTime, {
|
||||
userId: id,
|
||||
success: !!result
|
||||
});
|
||||
return result;
|
||||
}
|
||||
catch (error) {
|
||||
logError('UserRepository.activate error', error as Error);
|
||||
// Handle invalid UUID format
|
||||
if (error instanceof Error && error.message.includes('invalid input syntax for type uuid')) {
|
||||
throw new Error('Invalid user ID format');
|
||||
}
|
||||
throw new Error('Failed to activate user in database');
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user