feat: auth, compression, jwt, paste wip, roles, ratelimiting

This commit is contained in:
2025-11-24 21:50:26 -05:00
parent 050f0bc935
commit 6ec1a7fa7b
26 changed files with 611 additions and 473 deletions
+6 -19
View File
@@ -1,5 +1,5 @@
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using SharpbinV3.DTOs;
using SharpbinV3.Services;
namespace SharpbinV3.Controllers
@@ -10,21 +10,7 @@ namespace SharpbinV3.Controllers
{
private readonly IUserService _userService = userService;
[HttpPost]
public async Task<IActionResult> Create([FromBody] CreateUserDto dto)
{
if (await _userService.GetByUsername(dto.Username) != null)
return Conflict("Username already exists.");
if (!string.IsNullOrEmpty(dto.Email) && await _userService.GetByEmail(dto.Email) != null)
return Conflict("Email already exists.");
var user = await _userService.CreateUser(dto.Username, dto.Password, dto.Email, dto.DisplayName);
return CreatedAtAction(nameof(GetByUid), new { uid = user.UID }, new { user.UID, user.Username, user.UUID });
}
[HttpGet("{uid:int}")]
[HttpGet("{uid}")]
public async Task<IActionResult> GetByUid(int uid)
{
var user = await _userService.GetByUID(uid);
@@ -32,15 +18,16 @@ namespace SharpbinV3.Controllers
return Ok(new { user.UID, user.Username, user.UUID, user.DisplayName });
}
[HttpGet("username/{username:string}")]
[HttpGet("username/{username}")]
public async Task<IActionResult> GetByUsername(string username)
{
var user = await _userService.GetByUsername(username);
if (user == null) return NotFound();
return Ok(new { user.UID, user.Username, user.UUID, user.DisplayName });
}
[HttpGet("uuid/{uuid:guid}")]
public async Task<IActionResult> GetByUuid(Guid uuid)
[HttpGet("uuid/{uuid}")]
[Authorize]
public async Task<IActionResult> GetByUUID(Guid uuid)
{
var user = await _userService.GetByUUID(uuid);
if (user == null) return NotFound();