Skip to main content
nathan_h
Staff & Editor
Staff & Editor
October 22, 2024

Technical Tip: How to customize the login error on Replacement Page of Web Filter Block Override using Javascript

  • October 22, 2024
  • 0 replies
  • 609 views
Description

 

This article describes how to change the login error on Web Filter Block Override. When configuring Authenticate on the FortiGuard Category-Based Filter, it will require the user to authenticate. If the user does not belong to the group that is allowed to access the site based on category, it will show 'Invalid username and/or password'.

 

Scope

 

FortiGate.

 

Solution

 

FortiGate configuration:

 

Web filter Profile:

Advertising category set to Authenticate -> Select User Groups: WF_Advertising.

user_advertising is a member of the Group WF_Advertising.

 

2024-10-18 16 09 52.png

 

Brokerage and Trading category set to Authenticate -> Select User Groups: WF_Brokerage.

 

2024-10-18 16 11 52.png

 

Firewall Policy:

 

2024-10-18 16 17 45.png

 

Visit an Advertising Website -> Select Proceed -> Enter username and password user_advertising -> Select Continue -> Website is accessible.

 

2024-10-18 16 26 55.png

 

 

 

2024-10-18 16 19 54.png

 

2024-10-18 16 20 07.png

 

Visit a Brokerage and Trading Website -> Select Proceed -> Enter username and password user_advertising -> Select Continue.

 

2024-10-18 16 28 21.png 

 

2024-10-18 16 28 39.png

 

'Invalid username and/or password' is seen even if the username and password are correct. user_advertising is not a member of WF_Brokerage Group thus the website is inaccessible.

 

2024-10-18 16 28 49.png

 

 

The error message can be changed on the replacement Page with JavaScript script.

 

System -> Replacement Messages -> Extended View -> FortiGuard Web Filtering -> FortiGuard Override Page.

 

2024-10-18 16 35 40.png

 

Edit FortiGuard Override Page -> Scroll down -> Copy and paste the script below after the tag '</body>.' -> Select Save.

 

 <script>
const fonts = document.getElementsByTagName('font');
const errorprompt = fonts[0];
let custom_message_here = 'Invalid username and/or password or you are not part of the group that is allowed to access the website category';
console.log(custom_message_here);
errorprompt.innerHTML = custom_message_here; 
</script>

 

2024-10-18 16 41 24.png

 

Visit a Brokerage and Trading website -> Select Proceed -> Enter username and password user_advertising -> Select Continue

 

2024-10-18 16 52 36.png