531b3a7fef
- Redesigned login page with two-panel layout and branding - Added HexaDistro logo and theme toggle to sidebar/header - Refactored user update: roles via update endpoint, removed assignRole API/controller - Extended UpdateUserRequest for username, role, password changes - UserService.UpdateAsync syncs changes with AuthHex, with rollback - Stock balances client dedupes by itemId-locationId - Middleware matcher excludes static assets from auth checks - Improved localStorage clearing for user context - Added lucide-react for icons - Minor UI/code cleanups for consistency and UX
48 lines
1.5 KiB
C#
48 lines
1.5 KiB
C#
using Microsoft.AspNetCore.Mvc;
|
|
|
|
namespace Distribution.Features.User;
|
|
|
|
[ApiController]
|
|
[Route("api/users")]
|
|
public class UserController(UserService service) : ControllerBase
|
|
{
|
|
[HttpGet]
|
|
public async Task<IActionResult> GetAll() =>
|
|
Ok(await service.GetAllAsync());
|
|
|
|
[HttpGet("{id:guid}")]
|
|
public async Task<IActionResult> GetById(Guid id)
|
|
{
|
|
var result = await service.GetByIdAsync(id);
|
|
return result is null ? NotFound() : Ok(result);
|
|
}
|
|
|
|
[HttpPost]
|
|
public async Task<IActionResult> Create(CreateUserRequest request, CancellationToken ct)
|
|
{
|
|
var result = await service.CreateAsync(request, ct);
|
|
return CreatedAtAction(nameof(GetById), new { id = result.Id }, result);
|
|
}
|
|
|
|
[HttpPut("{id:guid}")]
|
|
public async Task<IActionResult> Update(Guid id, UpdateUserRequest request, CancellationToken ct)
|
|
{
|
|
var result = await service.UpdateAsync(id, request, ct);
|
|
return result is null ? NotFound() : Ok(result);
|
|
}
|
|
|
|
[HttpPut("{id:guid}/scope")]
|
|
public async Task<IActionResult> AssignScope(Guid id, AssignUserScopeRequest request, CancellationToken ct)
|
|
{
|
|
var updated = await service.AssignScopeAsync(id, request, ct);
|
|
return updated ? NoContent() : NotFound();
|
|
}
|
|
|
|
[HttpDelete("{id:guid}")]
|
|
public async Task<IActionResult> Deactivate(Guid id, CancellationToken ct)
|
|
{
|
|
var deactivated = await service.DeactivateAsync(id, ct);
|
|
return deactivated ? NoContent() : NotFound();
|
|
}
|
|
}
|