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

@@ -228,6 +228,8 @@ public class AuthController : ControllerBase
var refreshToken = Request.Cookies["refreshToken"];
if (!string.IsNullOrEmpty(refreshToken))
await _auth.RevokeRefreshTokenAsync(refreshToken);
var userId = int.Parse(User.FindFirstValue(ClaimTypes.NameIdentifier) ?? User.FindFirstValue("sub") ?? "0");
await _auth.RemoveMicrosoftTokenCacheAsync(userId);
Response.Cookies.Delete("refreshToken");
return NoContent();
}
@@ -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);
}
}
+1
View File
@@ -1,5 +1,6 @@
FROM mcr.microsoft.com/dotnet/aspnet:10.0 AS base
ARG APP_UID=1000
RUN mkdir -p /var/lib/universe/entra-cache && chown -R $APP_UID:$APP_UID /var/lib/universe
USER $APP_UID
WORKDIR /app
EXPOSE 8080
+5 -1
View File
@@ -144,7 +144,11 @@ builder.Services.AddScoped<IGamificationService, GamificationService>();
builder.Services.AddScoped<IAchievementService, AchievementService>();
builder.Services.AddScoped<ILlmAnalysisService, LlmAnalysisService>();
builder.Services.AddScoped<IScheduleSyncService, ScheduleSyncService>();
builder.Services.AddScoped<IMicrosoftAuthClient, MicrosoftAuthClient>();
builder.Services.AddSingleton<EntraTokenCacheStore>();
builder.Services.AddHttpClient<IMicrosoftAuthClient, MicrosoftAuthClient>(client =>
{
client.Timeout = TimeSpan.FromSeconds(10);
});
builder.Services.AddScoped<INotificationService, NotificationService>();
builder.Services.AddScoped<INotificationProvider, EmailNotificationProvider>();
builder.Services.AddSingleton<INotificationScheduler, QuartzNotificationScheduler>();
+72
View File
@@ -2439,6 +2439,75 @@
]
}
},
"/api/v1/users/me/photo": {
"get": {
"tags": [
"ProfilePhoto"
],
"summary": "Получить фото текущего пользователя из Microsoft Entra.",
"description": "**Required:** any authenticated user",
"responses": {
"200": {
"description": "OK"
},
"401": {
"description": "Unauthorized",
"content": {
"image/jpeg": {
"schema": {
"$ref": "#/components/schemas/ProblemDetails"
}
},
"image/png": {
"schema": {
"$ref": "#/components/schemas/ProblemDetails"
}
},
"image/gif": {
"schema": {
"$ref": "#/components/schemas/ProblemDetails"
}
},
"image/webp": {
"schema": {
"$ref": "#/components/schemas/ProblemDetails"
}
}
}
},
"404": {
"description": "Not Found",
"content": {
"image/jpeg": {
"schema": {
"$ref": "#/components/schemas/ProblemDetails"
}
},
"image/png": {
"schema": {
"$ref": "#/components/schemas/ProblemDetails"
}
},
"image/gif": {
"schema": {
"$ref": "#/components/schemas/ProblemDetails"
}
},
"image/webp": {
"schema": {
"$ref": "#/components/schemas/ProblemDetails"
}
}
}
}
},
"security": [
{
"Bearer": [ ]
}
]
}
},
"/api/v1/reviews": {
"post": {
"tags": [
@@ -6542,6 +6611,9 @@
{
"name": "Notifications"
},
{
"name": "ProfilePhoto"
},
{
"name": "Reviews"
},