Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -12,11 +12,16 @@ if 'phone_number' not in st.session_state:
|
|
12 |
st.session_state['phone_number'] = '9522583980' # Default phone number
|
13 |
if 'password' not in st.session_state:
|
14 |
st.session_state['password'] = ''
|
|
|
|
|
15 |
|
16 |
# Function to hash a password
|
17 |
def hash_password(password):
|
18 |
return hashlib.sha256(password.encode()).hexdigest()[:6]
|
19 |
|
|
|
|
|
|
|
20 |
# Mobile Phone field with emoji
|
21 |
st.sidebar.text_input("π± Mobile Phone", key='phone_number')
|
22 |
|
@@ -29,24 +34,27 @@ if st.sidebar.button('Save Password'):
|
|
29 |
st.session_state['password'] = hashed_password
|
30 |
st.sidebar.success("Password set successfully!")
|
31 |
|
32 |
-
#
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
# Send the SMS
|
37 |
-
tf.sendSMS(recipient=st.session_state['phone_number'], text=f"Your verification link: {verification_url}")
|
38 |
st.sidebar.success("Verification link sent via SMS")
|
39 |
|
40 |
-
#
|
41 |
-
|
42 |
-
if
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
|
|
|
|
|
|
|
|
|
|
|
12 |
st.session_state['phone_number'] = '9522583980' # Default phone number
|
13 |
if 'password' not in st.session_state:
|
14 |
st.session_state['password'] = ''
|
15 |
+
if 'hash' not in st.session_state:
|
16 |
+
st.session_state['hash'] = ''
|
17 |
|
18 |
# Function to hash a password
|
19 |
def hash_password(password):
|
20 |
return hashlib.sha256(password.encode()).hexdigest()[:6]
|
21 |
|
22 |
+
# Base URL for the verification link
|
23 |
+
base_url = "https://huggingface.co/spaces/awacke1/RT-SMS-Phone-Verify"
|
24 |
+
|
25 |
# Mobile Phone field with emoji
|
26 |
st.sidebar.text_input("π± Mobile Phone", key='phone_number')
|
27 |
|
|
|
34 |
st.session_state['password'] = hashed_password
|
35 |
st.sidebar.success("Password set successfully!")
|
36 |
|
37 |
+
# Function to send verification SMS
|
38 |
+
def send_verification_sms():
|
39 |
+
verification_url = f"{base_url}?hash={st.session_state['password']}"
|
40 |
+
tf.sendSMS(recipient=st.session_state['phone_number'], text=f"Verify here: {verification_url}")
|
|
|
|
|
41 |
st.sidebar.success("Verification link sent via SMS")
|
42 |
|
43 |
+
# Check if the hash parameter is provided
|
44 |
+
query_params = st.experimental_get_query_params()
|
45 |
+
if 'hash' in query_params:
|
46 |
+
st.session_state['hash'] = query_params['hash'][0]
|
47 |
+
with open('LoggedConfirmations.txt', 'a') as log_file:
|
48 |
+
log_file.write(f"{st.session_state['phone_number']}\n")
|
49 |
+
st.write("User has authenticated using text")
|
50 |
+
|
51 |
+
# Show verification button if hash is not in session
|
52 |
+
if not st.session_state['hash']:
|
53 |
+
if st.sidebar.button('Send Verify Request'):
|
54 |
+
send_verification_sms()
|
55 |
+
|
56 |
+
# Display history log
|
57 |
+
st.write("## Verification History")
|
58 |
+
with open('LoggedConfirmations.txt', 'r') as log_file:
|
59 |
+
history = log_file.read()
|
60 |
+
st.text(history)
|