Skip to content

Commit 7ad53d3

Browse files
committed
throw errors instead of returning messages for invalid authentication method states
1 parent e156ea9 commit 7ad53d3

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

Modules/CIPPCore/Public/Set-CIPPAuthenticationPolicy.ps1

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ function Set-CIPPAuthenticationPolicy {
5858
'SMS' {
5959
if ($State -eq 'enabled') {
6060
Write-LogMessage -headers $Headers -API $APIName -tenant $Tenant -message "Setting $AuthenticationMethodId to enabled is not allowed" -sev Error
61-
return "Setting $AuthenticationMethodId to enabled is not allowed"
61+
throw "Setting $AuthenticationMethodId to enabled is not allowed"
6262
}
6363
}
6464

@@ -89,15 +89,15 @@ function Set-CIPPAuthenticationPolicy {
8989
# Disallow enabling voice
9090
if ($State -eq 'enabled') {
9191
Write-LogMessage -headers $Headers -API $APIName -tenant $Tenant -message "Setting $AuthenticationMethodId to enabled is not allowed" -sev Error
92-
return "Setting $AuthenticationMethodId to enabled is not allowed"
92+
throw "Setting $AuthenticationMethodId to enabled is not allowed"
9393
}
9494
}
9595

9696
# Email OTP
9797
'Email' {
9898
if ($State -eq 'enabled') {
9999
Write-LogMessage -headers $Headers -API $APIName -tenant $Tenant -message "Setting $AuthenticationMethodId to enabled is not allowed" -sev Error
100-
return "Setting $AuthenticationMethodId to enabled is not allowed"
100+
throw "Setting $AuthenticationMethodId to enabled is not allowed"
101101
}
102102
}
103103

@@ -115,7 +115,7 @@ function Set-CIPPAuthenticationPolicy {
115115
}
116116
Default {
117117
Write-LogMessage -headers $Headers -API $APIName -tenant $Tenant -message "Somehow you hit the default case with an input of $AuthenticationMethodId . You probably made a typo in the input for AuthenticationMethodId. It`'s case sensitive." -sev Error
118-
return "Somehow you hit the default case with an input of $AuthenticationMethodId . You probably made a typo in the input for AuthenticationMethodId. It`'s case sensitive."
118+
throw "Somehow you hit the default case with an input of $AuthenticationMethodId . You probably made a typo in the input for AuthenticationMethodId. It`'s case sensitive."
119119
}
120120
}
121121
# Set state of the authentication method

0 commit comments

Comments
 (0)