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.
Project description
:lock: 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.
The login form collapses after login to free screen-space.
[!WARNING]
Passwords are saved as plain text. Use with caution.
:computer: Demo app
:construction: Installation
- Install
st-login-form
pip install st-login-form
- Create a Supabase project as mentioned here
- Create a table to store the usernames and passwords. The table name and column names can be as per your choice.
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;
- Follow the rest of the steps from here 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.
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")
🤗 Want to support my work?
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for st_login_form-0.2.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ba0a19dfac72a3a98dcbbd61f71922e9bfb5e57094eb6b1df6e5d522b34399b0 |
|
MD5 | 05e14da1d93ddf3d6ce048c81df78ad9 |
|
BLAKE2b-256 | 7a4a873ba1e6ef68c5708707411d29d69b274bcfc259d72545265081ec6f36cd |