From a4295c6c520a2afb9f4d6c4e7dea4c17f04a8dec Mon Sep 17 00:00:00 2001 From: Oleksandr Bezdieniezhnykh Date: Mon, 22 Sep 2025 00:34:37 +0300 Subject: [PATCH] fix bugs, improve security --- Azaion.Common/Azaion.Common.csproj | 2 +- Azaion.Services/Azaion.Services.csproj | 2 +- Azaion.Services/UserService.cs | 2 +- Azaion.Test/UserServiceTest.cs | 2 ++ env/api/env.ps1 | 6 +++--- 5 files changed, 8 insertions(+), 6 deletions(-) diff --git a/Azaion.Common/Azaion.Common.csproj b/Azaion.Common/Azaion.Common.csproj index 2ca3088..b6648be 100644 --- a/Azaion.Common/Azaion.Common.csproj +++ b/Azaion.Common/Azaion.Common.csproj @@ -9,7 +9,7 @@ - + diff --git a/Azaion.Services/Azaion.Services.csproj b/Azaion.Services/Azaion.Services.csproj index 1b9f5e8..31a44f7 100644 --- a/Azaion.Services/Azaion.Services.csproj +++ b/Azaion.Services/Azaion.Services.csproj @@ -22,7 +22,7 @@ - + diff --git a/Azaion.Services/UserService.cs b/Azaion.Services/UserService.cs index 8de41f0..6bc6b02 100644 --- a/Azaion.Services/UserService.cs +++ b/Azaion.Services/UserService.cs @@ -122,7 +122,7 @@ public class UserService(IDbFactory dbFactory, ICache cache) : IUserService private async Task UpdateLastLoginDate(User user, CancellationToken ct = default) { - await dbFactory.Run(async db => + await dbFactory.RunAdmin(async db => await db.Users.UpdateAsync(x => x.Email == user.Email, u => new User { LastLogin = DateTime.UtcNow diff --git a/Azaion.Test/UserServiceTest.cs b/Azaion.Test/UserServiceTest.cs index 01a59e4..b364444 100644 --- a/Azaion.Test/UserServiceTest.cs +++ b/Azaion.Test/UserServiceTest.cs @@ -18,6 +18,8 @@ public class UserServiceTest })); var userService = new UserService(dbFactory, new MemoryCache()); var user = await userService.GetByEmail("spielberg@azaion.com"); + if (user == null) + throw new Exception("User not found"); var res = await userService.CheckHardwareHash(user, "CPU: AMD Ryzen 9 3900XT 12-Core Processor. GPU: Microsoft Remote Display Adapter. Memory: 67037080. DriveSerial: PHMB746301G6480DGN _00000001."); diff --git a/env/api/env.ps1 b/env/api/env.ps1 index 40c842a..ec5cd7b 100644 --- a/env/api/env.ps1 +++ b/env/api/env.ps1 @@ -6,6 +6,6 @@ & "setx" "foo" "bar" -setx ASPNETCORE_ConnectionStrings__AzaionDb Host=localhost;Database=azaion;Username=azaion_reader;Password=Az@1on_re@d!only@$Az; -setx ASPNETCORE_ConnectionStrings__AzaionDbAdmin Host=localhost;Database=azaion;Username=azaion_admin;Password=Az@1on_admin$$@r; -setx ASPNETCORE_JwtConfig__Secret sdkfjghbsdfklhjgvbsdkljfhbvasklhfgsdfvh \ No newline at end of file +setx ASPNETCORE_ConnectionStrings__AzaionDb Host=localhost;Database=azaion;Username=azaion_reader;Password=Az_read; +setx ASPNETCORE_ConnectionStrings__AzaionDbAdmin Host=localhost;Database=azaion;Username=azaion_admin;Password=Az_admin; +setx ASPNETCORE_JwtConfig__Secret jwt_secret