Skip to content

Commit

Permalink
Merge pull request #42 from JohnDuprey/dev
Browse files Browse the repository at this point in the history
Add pipeline support
  • Loading branch information
JohnDuprey authored Aug 30, 2024
2 parents 34c92bd + 4a1758d commit f989e8e
Showing 1 changed file with 18 additions and 16 deletions.
34 changes: 18 additions & 16 deletions DuoSecurity/Public/Admin API/Users/Register-DuoUser.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -26,32 +26,34 @@ function Register-DuoUser {
#>
[CmdletBinding(SupportsShouldProcess)]
Param(
[Parameter(Mandatory = $true)]
[Parameter(ValueFromPipelineByPropertyName = $true, Mandatory = $true)]
[string]$Username,

[Parameter(Mandatory = $true)]
[Parameter(ValueFromPipelineByPropertyName = $true, Mandatory = $true)]
[string]$Email,

[Parameter()]
[int]$ValidSecs = 2592000
)

$DuoRequest = @{
Method = 'POST'
Path = '/admin/v1/users/enroll'
Params = @{
username = $Username
email = $Email
valid_secs = $ValidSecs
process {
$DuoRequest = @{
Method = 'POST'
Path = '/admin/v1/users/enroll'
Params = @{
username = $Username
email = $Email
valid_secs = $ValidSecs
}
}
}

if ($PSCmdlet.ShouldProcess($Email)) {
$Request = Invoke-DuoRequest @DuoRequest
if ($Request.stat -ne 'OK') {
$Request
} else {
$Request.response
if ($PSCmdlet.ShouldProcess($Email)) {
$Request = Invoke-DuoRequest @DuoRequest
if ($Request.stat -ne 'OK') {
$Request
} else {
$Request.response
}
}
}
}

0 comments on commit f989e8e

Please sign in to comment.