From f5ce75598cda661a9cd7c4c38f00deb20a5a2511 Mon Sep 17 00:00:00 2001 From: Mikhail Trubnikov Date: Tue, 5 Dec 2023 09:14:51 +1000 Subject: [PATCH] =?UTF-8?q?fix(api):=20=D0=B2=20=D0=BA=D1=8D=D1=88=20?= =?UTF-8?q?=D0=B4=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5=D0=BD=D1=8B=20=D0=B4?= =?UTF-8?q?=D0=BE=D0=BF=D0=BE=D0=BB=D0=BD=D0=B8=D1=82=D0=B5=D0=BB=D1=8C?= =?UTF-8?q?=D0=BD=D1=8B=D0=B5=20=D0=B4=D0=B0=D0=BD=D0=BD=D1=8B=D0=B5=20?= =?UTF-8?q?=D0=BE=20=D0=BF=D0=BE=D0=BB=D1=8C=D0=B7=D0=BE=D0=B2=D0=B0=D1=82?= =?UTF-8?q?=D0=B5=D0=BB=D0=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- PARR.API/Authentication/Models/UserCache.cs | 5 +++++ PARR.API/Controllers/V1/TestController.cs | 5 +++++ PARR.API/Services/Implementations/AuthService.cs | 9 ++++++++- 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/PARR.API/Authentication/Models/UserCache.cs b/PARR.API/Authentication/Models/UserCache.cs index 5f4aa2fc..5f77509c 100644 --- a/PARR.API/Authentication/Models/UserCache.cs +++ b/PARR.API/Authentication/Models/UserCache.cs @@ -3,6 +3,11 @@ public class UserCache { public required string UserIp { get; set; } + + public string Name { get; set; } = string.Empty; + + public string Description { get; set; } = string.Empty; + public List Roles { get; set; } = new List(); } } diff --git a/PARR.API/Controllers/V1/TestController.cs b/PARR.API/Controllers/V1/TestController.cs index e23bea64..19fd0407 100644 --- a/PARR.API/Controllers/V1/TestController.cs +++ b/PARR.API/Controllers/V1/TestController.cs @@ -67,6 +67,11 @@ namespace PARR.API.Controllers.V1 } + /// + /// Записать в кэш и получить обратно значение из кэша + /// + /// + /// [HttpPost(ApiRoutes.Test.CreateCache)] public async Task CreateCache([FromBody] CaheRequestTest request) { diff --git a/PARR.API/Services/Implementations/AuthService.cs b/PARR.API/Services/Implementations/AuthService.cs index 0484e2ec..3e8c4a7b 100644 --- a/PARR.API/Services/Implementations/AuthService.cs +++ b/PARR.API/Services/Implementations/AuthService.cs @@ -63,7 +63,14 @@ namespace PARR.API.Services.Implementations } // пользователь есть, добавляем в КЭШ и возвращаем роли - var cacheData = new UserCache { UserIp = ipAddress, Roles = roles }; + var cacheData = new UserCache + { + UserIp = ipAddress, + Roles = roles, + Name = user!.Name, + Description = user.Description ?? string.Empty + }; + await cacheService.SetCachedDataAsync(GetAllowKey(ipAddress), cacheData, userCacheSettings.UserCacheTtl); return cacheData;