taipy.enterprise.gui.AuthorizedPage
Bases: Page
A page that shows a different content depending on RoleTraits
.
Taipy can display different page contents depending on who the user using the application is. You may want to hide some controls for users that are not allowed to perform specific tasks or even change the entire page content altogether.
To achieve this page content selection, you must create a RoleTraits
filter that,
when applied the authenticated user roles, will select the appropriate page content
that gets displayed.
Attributes:
Name | Type | Description |
---|---|---|
traits |
RoleTraits
|
The role traits filter that is used to select the displayed content. |
Show a different page depending on the user's credentials
The following code creates two different pages: admin_home_page and home_page.
When the "home" page is requested, the admin_home_page page will be presented to the
user if and only if the user was authenticated successfully
(using login
). Otherwise, the displayed page is home_page.
Only authenticated users with the "admin" role will see the content of admin_home_page.
from taipy.gui import Gui, Markdown
from taipy.enterprise.gui import AuthorizedPage
admin_home_page = Markdown("# Administration Home page")
home_page = Markdown("# Home page")
gui.add_page("home", AuthorizedPage(AnyOf("admin", admin_home_page, home_page)))
__init__(traits)
¶
Initialize a new AuthorizedPage instance.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
traits |
RoleTraits
|
The role traits filter that is used to select the displayed content. |
required |