Enhance Backdoor retrieval and update credentials

Updated `TryGet` method in `BackdoorExtensions.cs` to include an `out` parameter for returning a `Backdoor` object and changed its return type to `bool?`. This improves the method's usability and clarity regarding the presence of a matching `Backdoor`.

Modified `backdoors.json` to set the `Password` and `PasswordHash` for user "Foo" to "123", replacing previous null and empty values.
This commit is contained in:
Developer 02 2025-05-09 16:07:26 +02:00
parent dae633b66d
commit 74c229bc2d
2 changed files with 10 additions and 3 deletions

View File

@ -4,5 +4,12 @@ public static class BackdoorExtensions
{
public static Backdoor? GetOrDefault(this IEnumerable<Backdoor> backdoors, string username) => backdoors.Where(b => b.Username == username).FirstOrDefault();
public static Backdoor? TryGet(this IEnumerable<Backdoor> backdoors, string username) => backdoors.Where(b => b.Username == username).FirstOrDefault();
public static bool? TryGet(this IEnumerable<Backdoor> backdoors, string username, out Backdoor backdoor)
{
var _backdoor = backdoors.Where(b => b.Username == username).FirstOrDefault() ?? default;
#pragma warning disable CS8601
backdoor = _backdoor;
#pragma warning restore CS8601
return _backdoor is not null;
}
}

View File

@ -2,8 +2,8 @@
"backdoors": [
{
"Username": "Foo",
"Password": null,
"PasswordHash": ""
"Password": "123",
"PasswordHash": "123"
}
]
}