mirror of
https://github.com/azaion/admin.git
synced 2026-04-22 09:06:33 +00:00
move hw set and queue offset to user rest entitiy
switch to body email set
This commit is contained in:
+12
-12
@@ -147,6 +147,18 @@ app.MapGet("/users",
|
|||||||
.RequireAuthorization(apiAdminPolicy)
|
.RequireAuthorization(apiAdminPolicy)
|
||||||
.WithOpenApi(op => new(op){ Summary = "List users by criteria"});
|
.WithOpenApi(op => new(op){ Summary = "List users by criteria"});
|
||||||
|
|
||||||
|
app.MapPut("/users/hardware/set",
|
||||||
|
async ([FromBody]SetHWRequest request, IUserService userService, ICache cache, CancellationToken cancellationToken) =>
|
||||||
|
await userService.UpdateHardware(request.Email, request.Hardware, cancellationToken: cancellationToken))
|
||||||
|
.RequireAuthorization(apiAdminPolicy)
|
||||||
|
.WithOpenApi(op => new OpenApiOperation(op){ Summary = "Sets user's hardware"});
|
||||||
|
|
||||||
|
app.MapPut("/users/queue-offsets/set",
|
||||||
|
async ([FromBody]SetUserQueueOffsetsRequest request, IUserService userService, CancellationToken cancellationToken)
|
||||||
|
=> await userService.UpdateQueueOffsets(request.Email, request.Offsets, cancellationToken))
|
||||||
|
.RequireAuthorization()
|
||||||
|
.WithOpenApi(op => new OpenApiOperation(op) { Summary = "Sets user's queue offsets" });
|
||||||
|
|
||||||
app.MapPost("/resources/{dataFolder?}",
|
app.MapPost("/resources/{dataFolder?}",
|
||||||
async ([FromRoute]string? dataFolder, IFormFile data, IResourcesService resourceService, CancellationToken cancellationToken)
|
async ([FromRoute]string? dataFolder, IFormFile data, IResourcesService resourceService, CancellationToken cancellationToken)
|
||||||
=> await resourceService.SaveResource(dataFolder, data, cancellationToken))
|
=> await resourceService.SaveResource(dataFolder, data, cancellationToken))
|
||||||
@@ -171,18 +183,6 @@ app.MapPost("/resources/get/{dataFolder?}", //Need to have POST method for secur
|
|||||||
}).RequireAuthorization()
|
}).RequireAuthorization()
|
||||||
.WithOpenApi(op => new OpenApiOperation(op){ Summary = "Gets encrypted by users Password and HardwareHash resources. POST method for secure password"});
|
.WithOpenApi(op => new OpenApiOperation(op){ Summary = "Gets encrypted by users Password and HardwareHash resources. POST method for secure password"});
|
||||||
|
|
||||||
app.MapPut("/resources/reset-hardware/{email}",
|
|
||||||
async ([FromRoute]string email, IUserService userService, ICache cache, CancellationToken cancellationToken) =>
|
|
||||||
await userService.UpdateHardware(email, cancellationToken: cancellationToken))
|
|
||||||
.RequireAuthorization(apiAdminPolicy)
|
|
||||||
.WithOpenApi(op => new OpenApiOperation(op){ Summary = "Resets hardware id in case of hardware change"});
|
|
||||||
|
|
||||||
app.MapPut("/users/queue-offsets/{email}",
|
|
||||||
async ([FromRoute] string email, UserQueueOffsets offsets, IUserService userService, CancellationToken cancellationToken)
|
|
||||||
=> await userService.UpdateQueueOffsets(email, offsets, cancellationToken))
|
|
||||||
.RequireAuthorization()
|
|
||||||
.WithOpenApi(op => new OpenApiOperation(op) { Summary = "Updates user queue offsets" });
|
|
||||||
|
|
||||||
app.UseExceptionHandler(_ => {});
|
app.UseExceptionHandler(_ => {});
|
||||||
|
|
||||||
app.Run();
|
app.Run();
|
||||||
|
|||||||
@@ -24,4 +24,4 @@ public class UserQueueOffsets
|
|||||||
public ulong AnnotationsOffset { get; set; }
|
public ulong AnnotationsOffset { get; set; }
|
||||||
public ulong AnnotationsConfirmOffset { get; set; }
|
public ulong AnnotationsConfirmOffset { get; set; }
|
||||||
public ulong AnnotationsCommandsOffset { get; set; }
|
public ulong AnnotationsCommandsOffset { get; set; }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,19 @@
|
|||||||
|
using FluentValidation;
|
||||||
|
|
||||||
|
namespace Azaion.Common.Requests;
|
||||||
|
|
||||||
|
public class SetHWRequest
|
||||||
|
{
|
||||||
|
public string Email { get; set; } = null!;
|
||||||
|
public string? Hardware { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public class SetHWRequestValidator : AbstractValidator<SetHWRequest>
|
||||||
|
{
|
||||||
|
public SetHWRequestValidator()
|
||||||
|
{
|
||||||
|
RuleFor(r => r.Email).NotEmpty()
|
||||||
|
.WithErrorCode(ExceptionEnum.EmailLengthIncorrect.ToString())
|
||||||
|
.WithMessage(_ => BusinessException.GetMessage(ExceptionEnum.EmailLengthIncorrect));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
using Azaion.Common.Entities;
|
||||||
|
|
||||||
|
namespace Azaion.Common.Requests;
|
||||||
|
|
||||||
|
public class SetUserQueueOffsetsRequest
|
||||||
|
{
|
||||||
|
public string Email { get; set; } = null!;
|
||||||
|
public UserQueueOffsets Offsets { get; set; } = null!;
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user