add check resource endpoint

This commit is contained in:
Alex Bezdieniezhnykh
2025-06-15 09:18:39 +03:00
parent 3be7062993
commit 1fcaba383e
3 changed files with 20 additions and 5 deletions
+11 -1
View File
@@ -186,7 +186,7 @@ app.MapPost("/resources/get/{dataFolder?}", //Need to have POST method for secur
if (user == null)
throw new UnauthorizedAccessException();
var hwHash = await userService.CheckHardwareHash(user, request);
var hwHash = await userService.CheckHardwareHash(user, request.Hardware);
var key = Security.GetApiEncryptionKey(user.Email, request.Password, hwHash);
var stream = await resourcesService.GetEncryptedResource(dataFolder, request.FileName, key, ct);
@@ -208,6 +208,16 @@ app.MapGet("/resources/get-installer/{dataFolder?}",
}).RequireAuthorization()
.WithOpenApi(op => new OpenApiOperation(op){ Summary = "Gets latest installer"});
app.MapPost("/resources/check",
async (CheckResourceRequest request, IAuthService authService, IUserService userService) =>
{
var user = await authService.GetCurrentUser();
if (user == null)
throw new UnauthorizedAccessException();
await userService.CheckHardwareHash(user, request.Hardware);
return true;
});
app.UseExceptionHandler(_ => {});
app.Run();