-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.py
76 lines (55 loc) · 2.09 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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
import random
import smtplib
import kivy_deps
import kivy
from kivy.app import App
from kivy.uix.label import Label
from kivy.uix.gridlayout import GridLayout
from kivy.core.window import Window
from kivy.properties import ObjectProperty
Window.size = (400, 400)
class MyGridLayout(GridLayout):
objname = ObjectProperty(None) #name passed from the text field
objemail = ObjectProperty(None) #email passed from the text field
objphone = ObjectProperty(None) #phone number passed from the text field
objotp = ObjectProperty(None) #OTP entered by the user passed from the text field
authotp = "0"
def sendbtn(self):
if (self.objemail.text != ""):
print(f"Name: {self.objname.text}")
print(f"Email: {self.objemail.text}")
print(f"Phone: {self.objphone.text}")
# create smtp session
s = smtplib.SMTP("smtp.gmail.com", 587) # 587 is a port number
# start TLS for E-mail security
s.starttls()
# Log in to your gmail account
s.login("otpgeneratorpython@gmail.com", "otpgenerator")
otp = random.randint(1000, 9999)
otp = str(otp) #generated otp
self.authotp = otp
s.sendmail("otpgeneratorpython@gmail.com", self.objemail.text , otp) # sending the mail
#close smtp session
s.quit()
print("OTP generated and sent successfully")
else :
print("Enter an email in the email field")
def authbtn(self):
if (self.objotp.text == self.authotp):
self.objotp.text = ""
self.objname.text = ""
self.objemail.text = ""
self.objphone.text = ""
print("\nUser Authorized ")
elif (self.authotp == ""):
print("Generate the OTP first")
else :
print("OTP is incorrect")
print("Unauthorized")
class MyOTPApp(App):
def build(self):
Window.clearcolor = (0.804, 0.361, 0.361,1)
return MyGridLayout()
if __name__ == "__main__" :
MyOTPApp=MyOTPApp()
MyOTPApp.run()