Skip to content
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

Closed
1 of 7 tasks
AlexandreSajus opened this issue Dec 12, 2024 · 3 comments · Fixed by #2347
Closed
1 of 7 tasks

Adding a custom button in the login visual element #2326

AlexandreSajus opened this issue Dec 12, 2024 · 3 comments · Fixed by #2347
Assignees
Labels
🖰 GUI Related to GUI ✨New feature 🟧 Priority: High Must be addressed as soon ❓ Question Can be unblocked with an answer

Comments

@AlexandreSajus
Copy link
Contributor

AlexandreSajus commented Dec 12, 2024

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

image

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

  • If applicable, a new demo code is provided to show the new feature in action.
  • Integration tests exhibiting how the functionality works are added.
  • Any new code is covered by a unit tested.
  • Check code coverage is at least 90%.
  • Related issue(s) in taipy-doc are created for documentation and Release Notes are updated.

Code of Conduct

  • I have checked the existing issues.
  • I am willing to work on this issue (optional)
@AlexandreSajus 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
@AlexandreSajus
Copy link
Contributor Author

A workaround using dialog:

image

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()

@FredLL-Avaiga FredLL-Avaiga self-assigned this Dec 17, 2024
@FredLL-Avaiga
Copy link
Member

Image

@jrobinAV
Copy link
Member

jrobinAV commented Dec 18, 2024

@FredLL-Avaiga

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
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants