st-login-form


Namest-login-form JSON
Version 0.2.2 PyPI version JSON
download
home_pagehttps://github.com/SiddhantSadangi/st_login_form
SummaryA streamlit component that creates a user login form connected to a Supabase DB. It lets users create a new username and password, login to an existing account, or login as an anonymous guest.
upload_time2024-01-28 16:31:16
maintainer
docs_urlNone
authorSiddhant Sadangi
requires_python>=3.8
license
keywords streamlit login
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # :lock: st-login-form
[![Downloads](https://static.pepy.tech/personalized-badge/st-login-form?period=total&units=international_system&left_color=black&right_color=brightgreen&left_text=Downloads)](https://pepy.tech/project/st-login-form)

A streamlit component that creates a user login form connected to a Supabase DB. It lets users create a new username and password, login to an existing account, or login as an anonymous guest.

![Form screenshot](assets/screenshot.png)

The login form collapses after login to free screen-space.

> [!WARNING]  
> Passwords are saved as plain text. Use with caution.

## :computer: Demo app
[![Open in Streamlit](https://static.streamlit.io/badges/streamlit_badge_black_white.svg)](https://st-lgn-form.streamlit.app/)

## :construction: Installation

1. Install `st-login-form`
```sh
pip install st-login-form
```
2. Create a Supabase project as mentioned [here](https://docs.streamlit.io/knowledge-base/tutorials/databases/supabase#sign-in-to-supabase-and-create-a-project)
3. Create a table to store the usernames and passwords. The table name and column names can be as per your choice.
```sql
CREATE TABLE users (
    username text not null default ''::text,
    password text not null,
    constraint users_pkey primary key (username),
    constraint users_username_key unique (username),
    constraint users_password_check check (
      (
        length(
          trim(
            both
            from
              password
          )
        ) > 1
      )
    ),
    constraint users_username_check check (
      (
        length(
          trim(
            both
            from
              username
          )
        ) > 1
      )
    )
  ) tablespace pg_default;
```
4. Follow the rest of the steps from [here](https://docs.streamlit.io/knowledge-base/tutorials/databases/supabase#copy-your-app-secrets-to-the-cloud) to connect your Streamlit app to Supabase


## :pen: Usage

On authentication, `login_form()` sets the `st.session_state['authenticated']` to `True`. This also collapses and disables the login form.  
`st.session_state['username']` is set to the provided username for a new or existing user, and to `None` for guest login.

```python
import streamlit as st

from st_login_form import login_form

client = login_form()

if st.session_state["authenticated"]:
    if st.session_state["username"]:
        st.success(f"Welcome {st.session_state['username']}")
    else:
        st.success("Welcome guest")
else:
    st.error("Not authenticated")
```

[![See demo in Streamlit](https://static.streamlit.io/badges/streamlit_badge_black_white.svg)](https://st-lgn-form.streamlit.app/)

## 🤗 Want to support my work?
<p align="center">
    <a href="https://www.buymeacoffee.com/siddhantsadangi" target="_blank"><img src="https://cdn.buymeacoffee.com/buttons/v2/default-yellow.png" alt="Buy Me A Coffee" style="height: 60px !important;width: 217px !important;">
    </a>
</p>

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/SiddhantSadangi/st_login_form",
    "name": "st-login-form",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": "",
    "keywords": "streamlit,login",
    "author": "Siddhant Sadangi",
    "author_email": "siddhant.sadangi@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/aa/10/bc2ebf11309fd9869a2e066131b9ab70de81a876602e00cfda75e5d5d5c8/st-login-form-0.2.2.tar.gz",
    "platform": null,
    "description": "# :lock: st-login-form\n[![Downloads](https://static.pepy.tech/personalized-badge/st-login-form?period=total&units=international_system&left_color=black&right_color=brightgreen&left_text=Downloads)](https://pepy.tech/project/st-login-form)\n\nA streamlit component that creates a user login form connected to a Supabase DB. It lets users create a new username and password, login to an existing account, or login as an anonymous guest.\n\n![Form screenshot](assets/screenshot.png)\n\nThe login form collapses after login to free screen-space.\n\n> [!WARNING]  \n> Passwords are saved as plain text. Use with caution.\n\n## :computer: Demo app\n[![Open in Streamlit](https://static.streamlit.io/badges/streamlit_badge_black_white.svg)](https://st-lgn-form.streamlit.app/)\n\n## :construction: Installation\n\n1. Install `st-login-form`\n```sh\npip install st-login-form\n```\n2. Create a Supabase project as mentioned [here](https://docs.streamlit.io/knowledge-base/tutorials/databases/supabase#sign-in-to-supabase-and-create-a-project)\n3. Create a table to store the usernames and passwords. The table name and column names can be as per your choice.\n```sql\nCREATE TABLE users (\n    username text not null default ''::text,\n    password text not null,\n    constraint users_pkey primary key (username),\n    constraint users_username_key unique (username),\n    constraint users_password_check check (\n      (\n        length(\n          trim(\n            both\n            from\n              password\n          )\n        ) > 1\n      )\n    ),\n    constraint users_username_check check (\n      (\n        length(\n          trim(\n            both\n            from\n              username\n          )\n        ) > 1\n      )\n    )\n  ) tablespace pg_default;\n```\n4. Follow the rest of the steps from [here](https://docs.streamlit.io/knowledge-base/tutorials/databases/supabase#copy-your-app-secrets-to-the-cloud) to connect your Streamlit app to Supabase\n\n\n## :pen: Usage\n\nOn authentication, `login_form()` sets the `st.session_state['authenticated']` to `True`. This also collapses and disables the login form.  \n`st.session_state['username']` is set to the provided username for a new or existing user, and to `None` for guest login.\n\n```python\nimport streamlit as st\n\nfrom st_login_form import login_form\n\nclient = login_form()\n\nif st.session_state[\"authenticated\"]:\n    if st.session_state[\"username\"]:\n        st.success(f\"Welcome {st.session_state['username']}\")\n    else:\n        st.success(\"Welcome guest\")\nelse:\n    st.error(\"Not authenticated\")\n```\n\n[![See demo in Streamlit](https://static.streamlit.io/badges/streamlit_badge_black_white.svg)](https://st-lgn-form.streamlit.app/)\n\n## \ud83e\udd17 Want to support my work?\n<p align=\"center\">\n    <a href=\"https://www.buymeacoffee.com/siddhantsadangi\" target=\"_blank\"><img src=\"https://cdn.buymeacoffee.com/buttons/v2/default-yellow.png\" alt=\"Buy Me A Coffee\" style=\"height: 60px !important;width: 217px !important;\">\n    </a>\n</p>\n",
    "bugtrack_url": null,
    "license": "",
    "summary": "A streamlit component that creates a user login form connected to a Supabase DB. It lets users create a new username and password, login to an existing account, or login as an anonymous guest.",
    "version": "0.2.2",
    "project_urls": {
        "Documentation": "https://github.com/SiddhantSadangi/st_login_form/blob/main/README.md",
        "Funding": "https://www.buymeacoffee.com/siddhantsadangi",
        "Homepage": "https://github.com/SiddhantSadangi/st_login_form"
    },
    "split_keywords": [
        "streamlit",
        "login"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "7a4a873ba1e6ef68c5708707411d29d69b274bcfc259d72545265081ec6f36cd",
                "md5": "05e14da1d93ddf3d6ce048c81df78ad9",
                "sha256": "ba0a19dfac72a3a98dcbbd61f71922e9bfb5e57094eb6b1df6e5d522b34399b0"
            },
            "downloads": -1,
            "filename": "st_login_form-0.2.2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "05e14da1d93ddf3d6ce048c81df78ad9",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 5167,
            "upload_time": "2024-01-28T16:31:14",
            "upload_time_iso_8601": "2024-01-28T16:31:14.506993Z",
            "url": "https://files.pythonhosted.org/packages/7a/4a/873ba1e6ef68c5708707411d29d69b274bcfc259d72545265081ec6f36cd/st_login_form-0.2.2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "aa10bc2ebf11309fd9869a2e066131b9ab70de81a876602e00cfda75e5d5d5c8",
                "md5": "48a1f0f52339017d59b3841426def5a3",
                "sha256": "391733dbd08ffdd1e60675eec3596698555ed47760aefd8596b7b57b303c66a6"
            },
            "downloads": -1,
            "filename": "st-login-form-0.2.2.tar.gz",
            "has_sig": false,
            "md5_digest": "48a1f0f52339017d59b3841426def5a3",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 5172,
            "upload_time": "2024-01-28T16:31:16",
            "upload_time_iso_8601": "2024-01-28T16:31:16.077714Z",
            "url": "https://files.pythonhosted.org/packages/aa/10/bc2ebf11309fd9869a2e066131b9ab70de81a876602e00cfda75e5d5d5c8/st-login-form-0.2.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-01-28 16:31:16",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "SiddhantSadangi",
    "github_project": "st_login_form",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [],
    "lcname": "st-login-form"
}
        
Elapsed time: 0.19506s