srbhavya01 commited on
Commit
d986cea
·
verified ·
1 Parent(s): 61df870

Delete login.py

Browse files
Files changed (1) hide show
  1. login.py +0 -67
login.py DELETED
@@ -1,67 +0,0 @@
1
- import streamlit as st
2
- import random
3
- import smtplib
4
- import os
5
- from email.mime.text import MIMEText
6
- from dotenv import load_dotenv
7
- from database import create_table, add_user
8
-
9
- load_dotenv()
10
- create_table()
11
-
12
- st.title("💪 FitPlan AI Login")
13
-
14
- EMAIL_USER = os.getenv("EMAIL_USER")
15
- EMAIL_PASS = os.getenv("EMAIL_PASS")
16
-
17
- if "otp" not in st.session_state:
18
- st.session_state.otp = None
19
-
20
- if "logged_in" not in st.session_state:
21
- st.session_state.logged_in = False
22
-
23
- email = st.text_input("Enter Email")
24
-
25
-
26
- def send_otp(email, otp):
27
-
28
- msg = MIMEText(f"Your FitPlan AI OTP is: {otp}")
29
- msg["Subject"] = "FitPlan AI Login OTP"
30
- msg["From"] = EMAIL_USER
31
- msg["To"] = email
32
-
33
- server = smtplib.SMTP_SSL("smtp.gmail.com", 465)
34
- server.login(EMAIL_USER, EMAIL_PASS)
35
- server.sendmail(EMAIL_USER, email, msg.as_string())
36
- server.quit()
37
-
38
-
39
- if st.button("Send OTP"):
40
-
41
- if email:
42
-
43
- otp = random.randint(100000, 999999)
44
- st.session_state.otp = otp
45
-
46
- send_otp(email, otp)
47
- add_user(email)
48
-
49
- st.success("OTP sent to your email")
50
-
51
- else:
52
- st.warning("Enter email first")
53
-
54
-
55
- user_otp = st.text_input("Enter OTP")
56
-
57
- if st.button("Verify OTP"):
58
-
59
- if str(st.session_state.otp) == user_otp:
60
-
61
- st.session_state.logged_in = True
62
- st.success("Login successful 🎉")
63
-
64
- st.switch_page("app.py")
65
-
66
- else:
67
- st.error("Invalid OTP")