-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adding a custom button in the login visual element #2326
Labels
🖰 GUI
Related to GUI
✨New feature
🟧 Priority: High
Must be addressed as soon
❓ Question
Can be unblocked with an answer
Comments
AlexandreSajus
added
🖰 GUI
Related to GUI
❓ Question
Can be unblocked with an answer
🟧 Priority: High
Must be addressed as soon
✨New feature
labels
Dec 12, 2024
A workaround using dialog: import os
from taipy.gui import Gui, notify
import taipy.gui.builder as tgb
from taipy.gui import notify
import taipy.gui.builder as tgb
from taipy.auth import hash_taipy_password, Credentials, Authenticator
import taipy.enterprise.gui as tp_enterprise
os.environ["TAIPY_AUTH_HASH"] = "taipy"
username = "login"
credentials = Credentials(user_name=username, roles=[])
passwords = {
"Florian": hash_taipy_password("mp153ap63"),
"Alexandre": hash_taipy_password("m4a1m995"),
}
roles = {
"Florian": ["admin", "TAIPY_ADMIN"],
"Alexandre": ["TAIPY_READER"],
}
authenticator = Authenticator(protocol="taipy", roles=roles, passwords=passwords)
username = ""
password = ""
login_dialog = True
def login(state):
try:
state.credentials = tp_enterprise.login(state, state.username, state.password)
notify(state, "success", f"Logged in as {state.username}...")
state.login_dialog = False
except Exception as e:
notify(state, "error", f"Login failed: {e}")
print(f"Login exception: {e}")
def guest_login(state):
notify(state, "success", "Logged in as Guest...")
state.login_dialog = False
with tgb.Page() as page:
with tgb.dialog("{login_dialog}", title="Welcome!"):
tgb.input("{username}", label="Username")
tgb.input("{password}", label="Password", password=True, on_action=login)
tgb.html("hr")
with tgb.layout("1 1 1"):
with tgb.part():
tgb.text("")
with tgb.part():
tgb.button("Guest Login", class_name="fullwidth", on_action=guest_login)
with tgb.part():
tgb.button("Login", class_name="fullwidth plain", on_action=login)
Gui(page).run() |
This issue was not part of the product backlog; it should not have been implemented. Last time we discussed it, we said we didn't want to implement it, but instead, we should communicate on the workaround. Is a revert possible? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
🖰 GUI
Related to GUI
✨New feature
🟧 Priority: High
Must be addressed as soon
❓ Question
Can be unblocked with an answer
Description
This feature request comes from a customer.
The customer wants a custom button in the login visual element next to the login button. This would allow him to create a "Login as guest" functionality where users could log in without entering credentials
What is the best way to do this? Should this be a feature in Taipy or should I just code a custom dialog visual element which satisfies his query?
Acceptance Criteria
Code of Conduct
The text was updated successfully, but these errors were encountered: