Jon Solow
commited on
Commit
·
116e690
1
Parent(s):
acdc2aa
Put new user form behind env var defaulted to true
Browse files- src/login.py +11 -7
src/login.py
CHANGED
@@ -1,4 +1,5 @@
|
|
1 |
import json
|
|
|
2 |
import pandas as pd
|
3 |
import re
|
4 |
import streamlit as st
|
@@ -6,6 +7,8 @@ from streamlit_gsheets import GSheetsConnection
|
|
6 |
from streamlit.runtime.secrets import AttrDict, secrets_singleton
|
7 |
from data_storage import get_user_id_if_email_exists, get_user, add_new_user, create_new_token_for_user
|
8 |
|
|
|
|
|
9 |
|
10 |
class HFFriendlyGSheetsConnection(GSheetsConnection):
|
11 |
# HF doesnt currently support nested secrets as in secrets.toml
|
@@ -56,13 +59,14 @@ def new_user_form():
|
|
56 |
if st.button("Existing User get Login link"):
|
57 |
existing_user_new_token()
|
58 |
else:
|
59 |
-
|
60 |
-
|
61 |
-
st.
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
|
|
66 |
|
67 |
|
68 |
def existing_user_new_token():
|
|
|
1 |
import json
|
2 |
+
import os
|
3 |
import pandas as pd
|
4 |
import re
|
5 |
import streamlit as st
|
|
|
7 |
from streamlit.runtime.secrets import AttrDict, secrets_singleton
|
8 |
from data_storage import get_user_id_if_email_exists, get_user, add_new_user, create_new_token_for_user
|
9 |
|
10 |
+
NEW_USER_ENABLED = bool(int(os.getenv("NEW_USER_ENABLED", 1)))
|
11 |
+
|
12 |
|
13 |
class HFFriendlyGSheetsConnection(GSheetsConnection):
|
14 |
# HF doesnt currently support nested secrets as in secrets.toml
|
|
|
59 |
if st.button("Existing User get Login link"):
|
60 |
existing_user_new_token()
|
61 |
else:
|
62 |
+
if NEW_USER_ENABLED:
|
63 |
+
"""Form to collect new user information and submit"""
|
64 |
+
with st.form("New User Registration"):
|
65 |
+
st.header("New User Registration")
|
66 |
+
st.write("After submitting, a url to login will be emailed to you.")
|
67 |
+
st.text_input("Email Address", key="new_user_email")
|
68 |
+
st.text_input("Name", key="new_user_name")
|
69 |
+
st.form_submit_button("Submit", on_click=new_user_submitted)
|
70 |
|
71 |
|
72 |
def existing_user_new_token():
|