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

form key values when forms are rendered with authenticator #132

Open
pmaye opened this issue Feb 9, 2024 · 7 comments
Open

form key values when forms are rendered with authenticator #132

pmaye opened this issue Feb 9, 2024 · 7 comments
Labels
help wanted Extra attention is needed

Comments

@pmaye
Copy link

pmaye commented Feb 9, 2024

Hi, I really appreciate the multiple options provided for signing in with numerous scenarios thought out.
However, I am wondering where to put/assign form key values when using multiple authenticator options
authenticator.forgot_password()
authenticator.login()
authenticator.reset_password()

my exact error message is:
There are multiple identical forms with key='Forgot password'.

none of these accept key values to provide different ids for different forms? unlike a normal st.form() which does allow a key value

where can i specify this?
thanks
Peter

@mkhorasani mkhorasani added the help wanted Extra attention is needed label Feb 10, 2024
@fsmosca
Copy link

fsmosca commented Mar 12, 2024

@pmaye

However, I am wondering where to put/assign form key values when using multiple authenticator options
authenticator.forgot_password()
authenticator.login()
authenticator.reset_password()

In the current source code, forgot_password() uses a key of "Forgot password", "Login" for longin() and "Reset password" for reset_password().

Form keys are not settable at present.

I have a branch from a fork where users can specify the form parameters as well as the authenticator parameters. If key is not specified the default key "Forgot password" will be used.

sample

    # Creating a forgot password widget
    try:
        username_of_forgotten_password, email_of_forgotten_password, new_random_password = \
            authenticator.forgot_password(
                'form_key_1',
                location='main',
                fields={'Form name': 'Forgot password with form key 1'},
                clear_on_submit=True
            )
        if username_of_forgotten_password:
            st.success('New password sent securely')
            # Random password to be transferred to the user securely
        elif username_of_forgotten_password == False:
            st.error('Username not found')
    except Exception as e:
        st.error(e)

    # Creating a forgot password widget
    try:
        username_of_forgotten_password, email_of_forgotten_password, new_random_password = \
            authenticator.forgot_password(clear_on_submit=True)
        if username_of_forgotten_password:
            st.success('New password sent securely')
            # Random password to be transferred to the user securely
        elif username_of_forgotten_password == False:
            st.error('Username not found')
    except Exception as e:
        st.error(e)

So far this is only implemented in Forgot password.

How to test

  • Create requirements.txt and add the libs

requirements.txt

streamlit==1.32.0
git+https://github.com/fsmosca/Streamlit-Authenticator.git@add-forgotpassword-key
  • Install the requirements with pip install -r requirements.txt

Test result on double forgot password

image

@fsmosca
Copy link

fsmosca commented Mar 13, 2024

Revised the login() on that branch. Now form key and other form parameter are supported.

Example

authenticator.login(
    'myformkey',
    clear_on_submit=True,
    location='main',
    fields={'Form name':'Login1', 'Username': 'Username1', 'Password':'Password1', 'Login':'Login1'}',
    max_concurrent_users=10
)

@mkhorasani
Copy link
Owner

Hi @pmaye, currently, all the widgets/forms by default have unique keys. If you wish to use multiples of the same widget then yes that would be an issue. Is that what you are trying to do?

@pmaye
Copy link
Author

pmaye commented Mar 26, 2024 via email

@mkhorasani
Copy link
Owner

*** Attention: This is an external email. Use caution responding, opening attachments or clicking on links. *** Hi Mohammad thanks for getting back to me on this. I think I have resolved this problem. However, now I am struggling with simply running streamlit as a localhost on my computer. Something is blocking it and I cannot figure out what. Any suggestions would be appreciated. thanks Peter Maye, PhD | Associate Professor Department of Reconstructive Sciences Center for Regenerative Medicine University of Connecticut Health Center phone: 860-679-7347 From: Mohammad Khorasani @.> Sent: Tuesday, March 26, 2024 4:02 PM To: mkhorasani/Streamlit-Authenticator @.> Cc: Maye,Peter @.>; Mention @.> Subject: Re: [mkhorasani/Streamlit-Authenticator] form key values when forms are rendered with authenticator (Issue #132) *** Attention: This is an external email. Use caution responding, opening attachments or clicking on links. *** Hi @pmayehttps://urldefense.com/v3/__https:/github.com/pmaye__;!!Cn_UX_p3!gQVGqlBUwzXD2QnrKzn0JncKsIVa3JuGfuTcEINTxXDtYg0kfPQOrKwgOj35ptK8Bt6D1kkye81lNE5gSbgxcGU$, currently, all the widgets/forms by default have unique keys. If you wish to use multiples of the same widget then yes that would be an issue. Is that what you are trying to do? — Reply to this email directly, view it on GitHubhttps://urldefense.com/v3/__https:/github.com/mkhorasani/Streamlit-Authenticator/issues/132*issuecomment-2021357370__;Iw!!Cn_UX_p3!gQVGqlBUwzXD2QnrKzn0JncKsIVa3JuGfuTcEINTxXDtYg0kfPQOrKwgOj35ptK8Bt6D1kkye81lNE5gXsuI4NA$, or unsubscribehttps://urldefense.com/v3/__https:/github.com/notifications/unsubscribe-auth/AI632LWKXM4BP5MKO7MYCFLY2HH3PAVCNFSM6AAAAABDCB5NG6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDAMRRGM2TOMZXGA__;!!Cn_UX_p3!gQVGqlBUwzXD2QnrKzn0JncKsIVa3JuGfuTcEINTxXDtYg0kfPQOrKwgOj35ptK8Bt6D1kkye81lNE5gxWVLbXY$. You are receiving this because you were mentioned.Message ID: @.@.>>

Sure, can you please provide more details/screenshots?

@pmaye
Copy link
Author

pmaye commented Mar 26, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

3 participants