Add factory reset functionality and update identity service
- Introduced a new DELETE endpoint `/api/admin/maintenance/factory-reset` for a complete reset of the admin panel, removing all users except the current admin and clearing various data. - Implemented the `FactoryReset` method in `AdminMaintenanceEndpoints` to handle the reset logic. - Added a new method `ListAllUserIdsExceptAsync` in `IIdentityService` to retrieve user IDs excluding a specified user, aiding in the factory reset process. - Updated the frontend to include a confirmation dialog for the factory reset action, enhancing user experience and safety. - Enhanced localization support for the new factory reset feature in both Russian and English, ensuring clarity for all users.
This commit is contained in:
@@ -23,6 +23,7 @@ public static class AdminMaintenanceEndpoints
|
||||
admin
|
||||
.MapDelete("/apps/disabled", DeleteDisabledApps)
|
||||
.Produces<MaintenanceCleanupResponseDto>();
|
||||
admin.MapDelete("/factory-reset", FactoryReset).Produces(StatusCodes.Status204NoContent);
|
||||
|
||||
return app;
|
||||
}
|
||||
@@ -58,6 +59,15 @@ public static class AdminMaintenanceEndpoints
|
||||
return ToResponse(result);
|
||||
}
|
||||
|
||||
private static async Task<IResult> FactoryReset(
|
||||
ISender sender,
|
||||
CancellationToken cancellationToken
|
||||
)
|
||||
{
|
||||
var result = await sender.Send(new FactoryResetCommand(), cancellationToken);
|
||||
return result.ToHttpResult();
|
||||
}
|
||||
|
||||
private static IResult ToResponse(Result<int> result) =>
|
||||
result.IsSuccess
|
||||
? Results.Ok(new MaintenanceCleanupResponseDto(result.Value))
|
||||
|
||||
Reference in New Issue
Block a user