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:
parent
dae633b66d
commit
74c229bc2d
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@ -2,8 +2,8 @@
|
||||
"backdoors": [
|
||||
{
|
||||
"Username": "Foo",
|
||||
"Password": null,
|
||||
"PasswordHash": ""
|
||||
"Password": "123",
|
||||
"PasswordHash": "123"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user