From cd70f54266d708867a1eb35870bc755bc5b2df32 Mon Sep 17 00:00:00 2001 From: ivar Date: Wed, 3 Dec 2025 21:49:20 +0100 Subject: Refactor db --- api/WhatApi/Extras/IConfigurationExtensions.cs | 9 +++++++++ api/WhatApi/Extras/PasswordHasher.cs | 23 +++++++++++++++++++++++ 2 files changed, 32 insertions(+) create mode 100644 api/WhatApi/Extras/IConfigurationExtensions.cs create mode 100644 api/WhatApi/Extras/PasswordHasher.cs (limited to 'api/WhatApi/Extras') diff --git a/api/WhatApi/Extras/IConfigurationExtensions.cs b/api/WhatApi/Extras/IConfigurationExtensions.cs new file mode 100644 index 0000000..5453699 --- /dev/null +++ b/api/WhatApi/Extras/IConfigurationExtensions.cs @@ -0,0 +1,9 @@ +namespace WhatApi.Extras; + +public static class IConfigurationExtensions +{ + extension(IConfiguration configuration) + { + public bool IsDevelopment => configuration.GetValue("ASPNETCORE_ENVIRONMENT") == "Development"; + } +} \ No newline at end of file diff --git a/api/WhatApi/Extras/PasswordHasher.cs b/api/WhatApi/Extras/PasswordHasher.cs new file mode 100644 index 0000000..88e69a7 --- /dev/null +++ b/api/WhatApi/Extras/PasswordHasher.cs @@ -0,0 +1,23 @@ +using Microsoft.AspNetCore.Identity; + +namespace WhatApi.Extras; + +public class VendorPasswordHasher : PasswordHasher; + +public static class PasswordHasher +{ + private static readonly VendorPasswordHasher _ = new(); + private static readonly User User = new() { + Name = "", + Email = "", + PasswordHash = "" + }; + + public static string HashPassword(string password) { + return _.HashPassword(User, password); + } + + public static PasswordVerificationResult VerifyHashedPassword(string hashedPassword, string providedPassword) { + return _.VerifyHashedPassword(User, hashedPassword, providedPassword); + } +} \ No newline at end of file -- cgit v1.3