Updated `DigitalData.Auth.API.csproj` to include new package references for improved security and functionality. Added a `Verify` method in the `Backdoor` class to securely check user credentials against plain text and hashed passwords. Introduced `BackdoorExtensions` with methods for easier retrieval of `Backdoor` instances by username.
22 lines
471 B
C#
22 lines
471 B
C#
namespace DigitalData.Auth.API.Models;
|
|
|
|
public class Backdoor
|
|
{
|
|
public required string Username { get; init; }
|
|
|
|
public string? Password { get; init; }
|
|
|
|
public string? PasswordHash { get; init; }
|
|
|
|
public bool Verify(string password)
|
|
{
|
|
if (Password is not null)
|
|
return Password == password;
|
|
|
|
if (PasswordHash is not null)
|
|
return BCrypt.Net.BCrypt.Verify(password, PasswordHash);
|
|
|
|
return false;
|
|
}
|
|
}
|