diff --git a/Module/Cmdlets/Fido/ConnectYubikeyFIDO2.cs b/Module/Cmdlets/Fido/ConnectYubikeyFIDO2.cs index 653d550..490485e 100644 --- a/Module/Cmdlets/Fido/ConnectYubikeyFIDO2.cs +++ b/Module/Cmdlets/Fido/ConnectYubikeyFIDO2.cs @@ -98,7 +98,7 @@ protected override void ProcessRecord() { if (fido2Session.AuthenticatorInfo.GetOptionValue(AuthenticatorOptions.clientPin) == OptionValue.False) { - WriteObject("Client PIN is not set."); + WriteWarning("Client PIN is not set."); return; } else if (fido2Session.AuthenticatorInfo.ForcePinChange == true) diff --git a/Module/Cmdlets/Fido/GetYubikeyFIDO2Credentials.cs b/Module/Cmdlets/Fido/GetYubikeyFIDO2Credentials.cs index a35f547..3156e1d 100644 --- a/Module/Cmdlets/Fido/GetYubikeyFIDO2Credentials.cs +++ b/Module/Cmdlets/Fido/GetYubikeyFIDO2Credentials.cs @@ -41,37 +41,27 @@ protected override void ProcessRecord() if (!RelyingParties.Any()) // Check if there are no relying parties { - WriteObject("No credentials found on the YubiKey."); + WriteWarning("No credentials found on the YubiKey."); return; } - - bool credentialsFound = false; // Track if any credentials are found - - foreach (RelyingParty RelyingParty in RelyingParties) + else { - var relayCredentials = fido2Session.EnumerateCredentialsForRelyingParty(RelyingParty); - - if (relayCredentials.Any()) // Check if this relying party has credentials + foreach (RelyingParty RelyingParty in RelyingParties) { - credentialsFound = true; - } + var relayCredentials = fido2Session.EnumerateCredentialsForRelyingParty(RelyingParty); - foreach (CredentialUserInfo user in relayCredentials) - { - Credentials credentials = new Credentials + foreach (CredentialUserInfo user in relayCredentials) { - Site = RelyingParty.Id, - Name = user.User.Name, - DisplayName = user.User.DisplayName, - }; - WriteObject(credentials); + Credentials credentials = new Credentials + { + Site = RelyingParty.Id, + Name = user.User.Name, + DisplayName = user.User.DisplayName, + }; + WriteObject(credentials); + } } } - - if (!credentialsFound) - { - WriteObject("No FIDO2 credentials found on the YubiKey."); - } } } diff --git a/Module/Cmdlets/Fido/SetYubikeyFIDO2.cs b/Module/Cmdlets/Fido/SetYubikeyFIDO2.cs index 5dbb998..7e2a36b 100644 --- a/Module/Cmdlets/Fido/SetYubikeyFIDO2.cs +++ b/Module/Cmdlets/Fido/SetYubikeyFIDO2.cs @@ -131,7 +131,7 @@ protected override void ProcessRecord() // Code to set minimum PIN length here. if (!fido2Session.TrySetPinConfig(MinimumPINLength, null, null)) - { + { throw new Exception("Failed to change the minimum PIN length."); } // Do it once more to force PIN change. diff --git a/Module/Cmdlets/Yubikey/ConnectYubikey.cs b/Module/Cmdlets/Yubikey/ConnectYubikey.cs index b689252..9a1bc1f 100644 --- a/Module/Cmdlets/Yubikey/ConnectYubikey.cs +++ b/Module/Cmdlets/Yubikey/ConnectYubikey.cs @@ -56,7 +56,7 @@ protected override void ProcessRecord() if (_yubikey is not null) { YubiKeyModule._yubikey = _yubikey; - WriteObject($"Connected to {PowershellYKText.FriendlyName(_yubikey)} with serial: {_yubikey.SerialNumber}."); + WriteInformation($"Connected to {PowershellYKText.FriendlyName(_yubikey)} with serial: {_yubikey.SerialNumber}.", new string[] { "YubiKey" }); } else { diff --git a/Module/Cmdlets/Yubikey/DisconnectYubikey.cs b/Module/Cmdlets/Yubikey/DisconnectYubikey.cs index 507201a..7271bab 100644 --- a/Module/Cmdlets/Yubikey/DisconnectYubikey.cs +++ b/Module/Cmdlets/Yubikey/DisconnectYubikey.cs @@ -10,7 +10,7 @@ protected override void BeginProcessing() { YubiKeyModule._yubikey = null; YubiKeyModule.clearPassword(); - WriteObject($"Disconnected from YubiKey."); + WriteInformation("Disconnected from YubiKey.", new string[] { "YubiKey" }); } } } \ No newline at end of file