feat: добавил отображение аватарки
gitea-push-docker.yml (push) Invalid workflow file
Backend CI / build-and-test (push) Successful in 3m34s
Frontend CI / build-and-check (push) Failing after 21s

This commit is contained in:
serega404 committed 2026-10-01 00:17:16 +03:00
1 parent 34e450815b
commit 038f0d89a6
22 files changed
+598 -28

No files matched your search

@@ -0,0 +1,37 @@
using System.Security.Claims;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using UniVerse.Application.Interfaces;
namespace UniVerse.Api.Controllers;
[ApiController]
[Authorize]
[Route("api/v1/users/me/photo")]
public sealed class ProfilePhotoController : ControllerBase
{
private readonly IAuthService _auth;
private readonly IMicrosoftAuthClient _microsoft;
public ProfilePhotoController(IAuthService auth, IMicrosoftAuthClient microsoft)
{
_auth = auth;
_microsoft = microsoft;
}
/// <summary>Получить фото текущего пользователя из Microsoft Entra.</summary>
[HttpGet]
[Produces("image/jpeg", "image/png", "image/gif", "image/webp")]
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
[ProducesResponseType(StatusCodes.Status404NotFound)]
public async Task<IActionResult> Get(CancellationToken cancellationToken)
{
var userId = int.Parse(User.FindFirstValue(ClaimTypes.NameIdentifier) ?? User.FindFirstValue("sub") ?? "0");
await _auth.GetCurrentUserAsync(userId);
Response.Headers.CacheControl = "private, no-store";
var photo = await _microsoft.GetPhotoAsync(userId, cancellationToken);
if (photo is null) return NotFound();
return File(photo.Content, photo.ContentType);
}
}