feat: login & registration; enhanced paste view; custom dropdown + search; navbar; global user access via store; auto token refresh; paste creation as user; /api/user/me, returns info on yourself including pastes;

fix: auth check
refactor: remove user UID api endpoint
This commit is contained in:
2025-12-28 13:54:01 -05:00
parent b9b14a3d5a
commit db1d8704a1
38 changed files with 1334 additions and 103 deletions
+35 -10
View File
@@ -10,15 +10,7 @@ namespace SharpbinV3.Server.Controllers
{
private readonly IUserService _userService = userService;
[HttpGet("{uid}")]
public async Task<IActionResult> GetByUid(int uid)
{
var user = await _userService.GetByUID(uid);
if (user == null) return NotFound();
return Ok(new { user.UID, user.Username, user.UUID, user.DisplayName });
}
[HttpGet("username/{username}")]
[HttpGet("{username}")]
public async Task<IActionResult> GetByUsername(string username)
{
var user = await _userService.GetByUsername(username);
@@ -26,12 +18,45 @@ namespace SharpbinV3.Server.Controllers
return Ok(new { user.UID, user.Username, user.UUID, user.DisplayName });
}
[HttpGet("uuid/{uuid}")]
[Authorize]
public async Task<IActionResult> GetByUUID(Guid uuid)
{
var user = await _userService.GetByUUID(uuid);
if (user == null) return NotFound();
return Ok(new { user.UID, user.Username, user.UUID, user.DisplayName });
}
[HttpGet("me")]
[Authorize]
public async Task<IActionResult> GetMe()
{
var httpUser = HttpContext.User;
var userUUID = httpUser?.FindFirst("UUID")?.Value;
if (userUUID is null)
return Unauthorized(new { message = "Invalid token." });
var user = await _userService.GetByUUID(Guid.Parse(userUUID), true);
if (user == null)
return NotFound();
var pastes = user.Pastes?.Select(p => new {
p.UUID,
p.Title,
p.Syntax,
p.Size,
p.TrueSize,
p.Views,
p.Visibility,
p.EditedAt,
p.ExpiresAt
});
return Ok(new {
user.UID,
user.Username,
user.UUID,
user.DisplayName,
user.Email,
user.LastLogin,
user.Roles,
user.Visibility,
Pastes = pastes
});
}
}
}