Skip to content

Commit 5793d1b

Browse files
committed
Refactor the password output of the AddUser endpoint so that the password is returned as a copyField
1 parent 19e4409 commit 5793d1b

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

Modules/CIPPCore/Public/Entrypoints/HTTP Functions/Identity/Administration/Users/Invoke-AddUser.ps1

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,15 +38,20 @@ Function Invoke-AddUser {
3838
} else {
3939
$CreationResults = New-CIPPUserTask -userobj $UserObj -APIName $APINAME -Headers $Request.Headers
4040
$body = [pscustomobject] @{
41-
'Results' = $CreationResults.Results
42-
'Username' = $CreationResults.username
43-
'Password' = $CreationResults.password
41+
'Results' = @(
42+
$CreationResults.Results[0],
43+
$CreationResults.Results[1],
44+
@{
45+
'resultText' = $CreationResults.Results[2]
46+
'copyField' = $CreationResults.password
47+
'state' = 'success'
48+
}
49+
)
4450
'CopyFrom' = @{
4551
'Success' = $CreationResults.CopyFrom.Success
4652
'Error' = $CreationResults.CopyFrom.Error
4753
}
4854
}
49-
5055
}
5156
# Associate values to output bindings by calling 'Push-OutputBinding'.
5257
Push-OutputBinding -Name Response -Value ([HttpResponseContext]@{

Modules/CIPPCore/Public/New-CIPPUserTask.ps1

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ function New-CIPPUserTask {
1313
$Results.Add('Created New User.')
1414
$Results.Add("Username: $($CreationResults.Username)")
1515
$Results.Add("Password: $($CreationResults.Password)")
16-
$Results.Add("$($CreationResults.Password)")
1716
} catch {
1817
$Results.Add("Failed to create user. $($_.Exception.Message)" )
1918
return @{'Results' = $Results }

0 commit comments

Comments
 (0)