-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
50 lines (47 loc) · 1.76 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import mysql.connector as db
import smtplib
import random
mydb=db.connect(host="localhost",passwd="root",user="root",database="netflix_data_analysis")
mycursor=mydb.cursor()
def user_auth():
count=None
email = input("Enter your email to login")
fetch_query = "select * from reg_users;"
mycursor.execute(fetch_query)
for i in mycursor:
if i[2] == email:
print("Login Successful !")
import dashboard
count = 1
break
if count == 0:
print("Login Error !")
print("#"*88)
print("******************* Enter 1 to LOGIN or 2 to REGISTER for new users *******************")
print("#"*88)
inp=int(input())
count=0
if inp==1:
user_auth()
elif inp==2:
name = input("ENTER YOUR NAME: ")
email = input("ENTER YOUR EMAIL: ")
otp = str(random.randint(100000,1000000))
SUBJECT = "OTP for Login"
TEXT = "HEY "+name+'!'"\r\n""\r\n"'Your OTP for login is: ' + otp+ "\r\n""\r\n"'Please enter the otp for further verification'"\r\n""\r\n"'Thank you !'
s = smtplib.SMTP('smtp.gmail.com', 587)
s.starttls()
s.login('[email protected]', 'apsj#12345678')
message = 'Subject: {}\n\n{}'.format(SUBJECT, TEXT)
s.sendmail('[email protected]', email, message)
s.quit()
print("An OTP was sent to the entered email address")
answer=int(input("Please enter the otp for verification"))
if answer == int(otp) :
query = "insert into reg_users (name,email) values (" + "'" + name + "'"+"," + "'" + email + "'" + ");"
mycursor.execute(query)
mydb.commit()
print("You have been successfully registered. Now please follow the instructions to successfully Login ")
user_auth()
else:
print('Login failed. Please Try Again')