mirror of
https://github.com/LD-Reborn/Berufsschule_HAM.git
synced 2025-12-20 15:01:56 +00:00
Implemented user settings view
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
using System.Globalization;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using Berufsschule_HAM.Models;
|
||||
using Berufsschule_HAM.Services;
|
||||
namespace Berufsschule_HAM.Helpers;
|
||||
|
||||
public static partial class UsersHelper
|
||||
@@ -39,6 +41,14 @@ public static partial class UsersHelper
|
||||
return cleaned;
|
||||
}
|
||||
|
||||
public static async Task<string> HashPassword(LdapService ldapService, string password)
|
||||
{
|
||||
AdminSettingsModel settings = await ldapService.GetAdminSettingsModelAsync();
|
||||
byte[] passwordBytes = Encoding.UTF8.GetBytes(password);
|
||||
byte[] hashedPassword = settings.hashAlgorithm?.ComputeHash(passwordBytes) ?? throw new Exception("Hash algorithm not instantiated yet");
|
||||
return $"{{{settings.DefaultHashAlgorithm.ToUpperInvariant()}}}{Convert.ToBase64String(hashedPassword)}";
|
||||
}
|
||||
|
||||
[GeneratedRegex("[^a-z]")]
|
||||
private static partial Regex AtoZ();
|
||||
}
|
||||
Reference in New Issue
Block a user