ERPNext.com Frappe Cloud Support Partners Foundation Frappe School

How to add authentication to portal pages or web pages

How to add authentication to portal pages or web pages .
Is thare any inbuild functionality provided by frappe to add login_required to Portal page or Web Page.
I have a custom app and i need to add authentication to few of my web pages.
Can any one please guide me

In your get_context method you may add something like this:

if frappe.session.user=='Guest':
    frappe.throw(_("You need to be logged in to access this page"), frappe.PermissionError)
1 Like

As mincerray explained you can add the context script under the web page section as shown in the below image.

1 Like

thanks for quick reply

Thanks Aadhil it worked