Pode.Web icon indicating copy to clipboard operation
Pode.Web copied to clipboard

Flash alerts missing from login.pode when using Oauth2

Open DanGough opened this issue 1 year ago • 2 comments

Current code in Pode 0.8.3 only displays the flash in the first branch of the if statement:

` $(if (!$data.Auth.IsOAuth2 -or ($data.Auth.GrantType -ieq 'password')) { Use-PodeWebPartialView -Path 'shared/_load' -Data @{ Content = $data.Content }

                if ($data.Flash['auth-error']) {
                    "<div class='alert alert-danger' role='alert'>
                        <span class='mdi mdi-alert-circle'></span>
                        <strong>$($data.Flash['auth-error'])</strong>
                    </div>"
                }

                "<button class='btn btn-lg btn-inbuilt-theme btn-block' type='submit'>
                    <span class='spinner-border spinner-border-sm' role='status' aria-hidden='true' style='display: none'></span>
                    Sign in
                </button>"
            }
            else {
                "<button class='btn btn-lg btn-inbuilt-theme btn-block' type='submit'>
                    <span class='spinner-border spinner-border-sm' role='status' aria-hidden='true' style='display: none'></span>
                    Sign in using OAuth2 ($($data.Auth.Name))
                </button>"
            })`

Therefore my login error does not get shown when using AzureAD sign-in. It works after copying the same code block to the else clause:

` $(if (!$data.Auth.IsOAuth2 -or ($data.Auth.GrantType -ieq 'password')) { Use-PodeWebPartialView -Path 'shared/_load' -Data @{ Content = $data.Content }

                if ($data.Flash['auth-error']) {
                    "<div class='alert alert-danger' role='alert'>
                        <span class='mdi mdi-alert-circle'></span>
                        <strong>$($data.Flash['auth-error'])</strong>
                    </div>"
                }

                "<button class='btn btn-lg btn-inbuilt-theme btn-block' type='submit'>
                    <span class='spinner-border spinner-border-sm' role='status' aria-hidden='true' style='display: none'></span>
                    Sign in
                </button>"
            }
            else {
                if ($data.Flash['auth-error']) {
                    "<div class='alert alert-danger' role='alert'>
                        <span class='mdi mdi-alert-circle'></span>
                        <strong>$($data.Flash['auth-error'])</strong>
                    </div>"
                }
                "<button class='btn btn-lg btn-inbuilt-theme btn-block' type='submit'>
                    <span class='spinner-border spinner-border-sm' role='status' aria-hidden='true' style='display: none'></span>
                    Sign in using OAuth2 ($($data.Auth.Name))
                </button>"
            })`

DanGough avatar Jul 03 '23 13:07 DanGough