mirror of
https://github.com/azaion/admin.git
synced 2026-04-22 10:26:34 +00:00
add check resource endpoint
This commit is contained in:
+11
-1
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user