Skip to content

Commit e89d305

Browse files
committed
Simplify value handling in AppManagement policy
learned more about .js - removed redundant coalescing I copied from other standards as baseline
1 parent aac2f7c commit e89d305

1 file changed

Lines changed: 8 additions & 8 deletions

File tree

Modules/CIPPCore/Public/Standards/Invoke-CIPPStandardAppManagementPolicy.ps1

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -45,20 +45,20 @@ function Invoke-CIPPStandardAppManagementPolicy {
4545
}
4646

4747
# Unwrap autoComplete values - frontend sends {label, value} objects, extract the string
48-
$passwordAdditionState = [string]($Settings.passwordCredentialsPasswordAddition.value ?? $Settings.passwordCredentialsPasswordAddition)
49-
$customPasswordState = [string]($Settings.passwordCredentialsCustomPasswordAddition.value ?? $Settings.passwordCredentialsCustomPasswordAddition)
50-
$passwordMaxLifetimeDays = $Settings.passwordCredentialsMaxLifetime.value ?? $Settings.passwordCredentialsMaxLifetime
51-
$keyMaxLifetimeDays = $Settings.keyCredentialsMaxLifetime.value ?? $Settings.keyCredentialsMaxLifetime
48+
$passwordAdditionState = [string]$Settings.passwordCredentialsPasswordAddition.value
49+
$customPasswordState = [string]$Settings.passwordCredentialsCustomPasswordAddition.value
50+
$passwordMaxLifetimeDays = $Settings.passwordCredentialsMaxLifetime
51+
$keyMaxLifetimeDays = $Settings.keyCredentialsMaxLifetime
5252

5353
# Convert user-entered days to ISO 8601 duration format (P<n>D)
54-
$passwordMaxLifetimeISO = if (-not [string]::IsNullOrWhiteSpace($passwordMaxLifetimeDays) -and $passwordMaxLifetimeDays -ne 'Select a value') { "P${passwordMaxLifetimeDays}D" } else { $null }
55-
$keyMaxLifetimeISO = if (-not [string]::IsNullOrWhiteSpace($keyMaxLifetimeDays) -and $keyMaxLifetimeDays -ne 'Select a value') { "P${keyMaxLifetimeDays}D" } else { $null }
54+
$passwordMaxLifetimeISO = if (-not [string]::IsNullOrWhiteSpace($passwordMaxLifetimeDays)) { "P${passwordMaxLifetimeDays}D" } else { $null }
55+
$keyMaxLifetimeISO = if (-not [string]::IsNullOrWhiteSpace($keyMaxLifetimeDays)) { "P${keyMaxLifetimeDays}D" } else { $null }
5656

5757
# Build desired password credential restrictions
5858
$desiredPasswordCredentials = [System.Collections.Generic.List[object]]::new()
5959

6060
# Password addition + symmetric key addition (mirrors password addition)
61-
if (-not [string]::IsNullOrWhiteSpace($passwordAdditionState) -and $passwordAdditionState -ne 'Select a value') {
61+
if (-not [string]::IsNullOrWhiteSpace($passwordAdditionState)) {
6262
$desiredPasswordCredentials.Add([ordered]@{
6363
restrictionType = 'passwordAddition'
6464
state = $passwordAdditionState
@@ -74,7 +74,7 @@ function Invoke-CIPPStandardAppManagementPolicy {
7474
}
7575

7676
# Custom password
77-
if (-not [string]::IsNullOrWhiteSpace($customPasswordState) -and $customPasswordState -ne 'Select a value') {
77+
if (-not [string]::IsNullOrWhiteSpace($customPasswordState)) {
7878
$desiredPasswordCredentials.Add([ordered]@{
7979
restrictionType = 'customPasswordAddition'
8080
state = $customPasswordState

0 commit comments

Comments
 (0)