OK guys I think I tried everything that is achievable and that, in my opinion, could make sense:
I went through the docs again here where everything about forms auth is documented, also regarding overriding the /login page:
I then tried to make a new “Login Dashboard” w/o authentication (as stated in the docs).
Here are the code bits:
New-UDTextbox -Id "tboxLoginUsername" -Label "Username" -Icon (New-UDIcon -Icon 'user') -Placeholder "john.doe@company.com"
New-UDElement -Tag "br"
New-UDTextbox -Label "Password" -Icon (New-UDIcon -Icon 'key') -Type password
New-UDElement -Tag "br"
New-UDButton -Text "Login" -Icon (New-UDIcon -Icon 'checkdouble') -OnClick {
# Get Typed Username
$Session:LoginUsername = (Get-UDElement -Id 'tboxLoginUsername').value
# Get Typed Password
$Session:LoginPasword = (Get-UDElement -Id 'tboxLoginPassword').value
# Try to set the Authentication Result
if ($Session:LoginUsername -eq 'Admin') {
$Result = [Security.AuthenticationResult]::new()
$Result.UserName = 'admin'
$Result.Success = $true
$authResult = New-PSUAuthenticationResult -Success -UserName 'admin' -Claims {
New-PSUAuthorizationClaim -Type 'TestRole' -Value 'HelloWorld'
}
Show-UDToast ($authResult | Out-String) -Duration 5000
Start-Sleep -Seconds 3
# redirecting to dashboard with Authentication enabled... but doesn't work. :-(
Invoke-UDRedirect 'https://localhost:5000/dashboard2/playground' -OpenInNewWindow
}
}
As you can see, at the end of the execution, if the user equals “admin” it should redirect to my dashboard2 which obviously has auth enabled…
Result?
Doesn’t work… You can try it yourself…
@adam Sorry for mentioning you… I really hate doing this… But could it be that there is an issue or a bug with the New-PSUAuthenticationResult or $Result.Success when called outside of your standard /Login form?
Or am I missing something else?
Sorry but I really don’t know how to proceed right now…
Thanks for your help,
Don