Errors around if else and pages and $Roles

Hosted IIS environment
PSU version 5.6.8

I am having issues starting an App and calling a different page based on an IF Else statement. I cannot get a Role match even though when I output the Roles to a table it is there. Also, the if statement has a submit form inside it but that submit dialog appears when the else page is to be displayed. So, it still loads an input box -onsubmit even though it is not part of the else page form.

If ($Roles -contains $LAPSRole){$Navigation = @(   New-UDListItem -Label "LAPSLookup" -OnClick { Invoke-UDRedirect -url "/LAPSLookup"})    $Pages = @()    $Pages = Get-UDPage -Name 'LAPSLookup'}Else {$Navigation = @(New-UDListItem -Label "Home" -OnClick { Invoke-UDRedirect -url "/Home"})$Pages = @() $Pages = Get-UDPage -Name 'Home'} New-UDApp -Title 'LAPSLookup' -Pages $Pages -Navigation $Navigation

I also tried the bit about using roles for pages.

$Pages = @() $Pages += New-UDPage -Name 'Administrators' -Content { New-UDTypography -Text 'Dashboard for user: $User' } -Role 'Administrator' $Pages += New-UDPage -Name 'Operators' -Content { New-UDTypography -Text 'Dashboard for user: $User' } -Role 'Operator' New-UDApp -Title 'Pages' -Pages $Pages

That did not work either as it does not respect the roles and continues to just whatever page it wants even when i set bogus role values.

I use this syntax which works fine for me. I don’t call pages specifically, but execute additional code based on roles.

if ("IT" -in $Roles) {
     # Role based code here …
}

Doing this suggestion still causes the submit form to break through somehow from the other section. I have tried this but end up with the same issue as a submit dialog from a different form pops up on the screen.

Thank you as I tried this but this does not work either as the same issue of the submit button from another form breaks through. UDProtect nor an if Else statements appear to keep a submit input box from coming through from a very specific form.