forked from phoenix/litellm-mirror
build(auth.py): send redirect url via magic link
This commit is contained in:
parent
1bfab87323
commit
189fcc0934
3 changed files with 18 additions and 8 deletions
14
ui/auth.py
14
ui/auth.py
|
@ -5,6 +5,8 @@ Uses supabase passwordless auth: https://supabase.com/docs/reference/python/auth
|
|||
|
||||
Remember to set your redirect url to 8501 (streamlit default).
|
||||
"""
|
||||
import logging
|
||||
logging.basicConfig(level=logging.DEBUG)
|
||||
import streamlit as st
|
||||
from dotenv import load_dotenv
|
||||
load_dotenv()
|
||||
|
@ -17,14 +19,18 @@ key: str = os.environ.get("SUPABASE_KEY")
|
|||
supabase: Client = create_client(url, key)
|
||||
|
||||
|
||||
def sign_in_with_otp(email: str):
|
||||
data = supabase.auth.sign_in_with_otp({"email": email})
|
||||
def sign_in_with_otp(email: str, redirect_url: str):
|
||||
data = supabase.auth.sign_in_with_otp({"email": email,
|
||||
"options": {
|
||||
"email_redirect_to": redirect_url
|
||||
}})
|
||||
print(f"data: {data}")
|
||||
# Redirect to Supabase UI with the return data
|
||||
st.write(f"Please check your email for a login link!")
|
||||
|
||||
|
||||
# Create the Streamlit app
|
||||
def auth_page():
|
||||
def auth_page(redirect_url: str):
|
||||
st.title("User Authentication")
|
||||
|
||||
# User email input
|
||||
|
@ -32,4 +38,4 @@ def auth_page():
|
|||
|
||||
# Sign in button
|
||||
if st.button("Sign In"):
|
||||
sign_in_with_otp(email)
|
||||
sign_in_with_otp(email, redirect_url=redirect_url)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue