Redirect to static page after failed login

Hi,
I’m using windows authentication mode (v2025.7) and I’m matching the windows user to a database user in User_CustomValidate(). If the matching record is not found in the database I return false to refuse the login.
However, the user is redirected to the login form and I want them to be redirected to another page with static content. How do I do that?
Thanks!

In User_CustomValidate() you may try to set a flash message, e.g.

FlashBag()->add("MyRedirectUrl", "MyStaticPage");

Then in Page_Load() server event of login page, you may try:

$url = FlashBag()->get("MyRedirectUrl")[0] ?? "";
if ($url) {
   $this->terminate($url);
}

Note: Pseudocode only, don’t just copy and paste, you need to modify as you need.