-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDB_con_FB.py
More file actions
140 lines (123 loc) · 4.36 KB
/
Copy pathDB_con_FB.py
File metadata and controls
140 lines (123 loc) · 4.36 KB
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
import pyrebase,requests
from tkinter import messagebox
import smtplib
from email.message import EmailMessage
import random,emoji
firebaseConfig = {
'apiKey': "",
'authDomain': "",
'projectId': "",
'storageBucket': "",
'messagingSenderId': "",
'appId': "",
'measurementId': "",
'databaseURL':""
#at the empty string get the data from u r firebase
#i removed due to privacy
}
firebase = pyrebase.initialize_app(firebaseConfig)
db = firebase.database()
auth=firebase.auth()
storage=firebase.storage()
#here we are using db!!
#this is for signup
def username_input(usr,password,emailid):
while True:
try:
a = db.child("Logininfo").child(usr).get().val()
print(type(a))
b = a['username']
print(type(b))
if usr == b:
print("username already exixted")
messagebox.showinfo(title="Username Exist!",message="Try another user name!!!")
return 0
break
except TypeError:
insert_data(usr,password,emailid)
return 1
#need to code here for checking the username!!!!
def insert_data(usr,password,emailid):
data = {
'username': usr, 'password': password, 'emailid': emailid
}
db.child("Logininfo").child(usr).set(data) # child is the table name another child name for own id
print("created")
#thiss is for passing the verification for the signup
def getting_data(usrname,passwordd):
login = db.child("Logininfo").child(usrname).get().val()
print(usrname)
login_pass=login['password']
print(login_pass)
if login_pass == passwordd:
print("fuked up")
c=db.child("Logininfo").child(usrname).get().val()
d=c['emailid']
print(d)
#we will call this to the smpt fuction to send the otp!!
otp_through1_mail(d)
else:
print("mffff")
#this is for otp to mail at signup side
def otp_through1_mail(usr_mail):
server = smtplib.SMTP_SSL('smtp.gmail.com',465) #default port server for sending mails 587
#WHEN U USE SMPT_SSL PORT NUMBER IS 465
# mails=["darklgnd100@gmail.com","tarunskt5678@gmail.com"]
global otp
otp = random.randrange(10000, 100000)
# print(otp)
print("OTP generated successfully")
a = emoji.emojize(":check_mark:")
a1 = emoji.emojize(":hollow_red_circle:")
a2 = emoji.emojize(":warning:")
a3 = emoji.emojize(":fast_reverse_button:")
a4 = emoji.emojize(":fast-forward_button:")
a5 = emoji.emojize(":atom_symbol:")
a6 = emoji.emojize(":love_letter:")
msg=EmailMessage()
msg['From']="akatsukiorganisationdev999@gmail.com"
msg['To']=usr_mail
msg['Subject']=str(a6)+"YOUR "+str(a1)+"TP"+str(a)
msg.set_content("Your OTP for Encryption_app is>>\n\n\n\n\n\n\t\t\t"+str(a3)+str(otp)+str(a4)+"\n\n\n\n\n\n\n\n\n\t\t\t\t"
"\t\t\t\n\n\n"+str(a5)+"BY-Akatsuki Organisation and "
"Development \n\n\n\n\n-----------------------------------------------------------------\n\n")
#login
server.login("akatsukiorganisationdev999@gmail.com","lgrztplkwseotosn")
server.send_message(msg)
print("otp went successfully to your mail")
server.quit()
#this is for otp verification
def opt_verification(usr_enters):
r = 0
if otp == int(usr_enters):
print(type(usr_enters))
print(otp)
print("Access Granted!")
r += 1
else:
print("Access Denied! or invalid code")
print("Authentication Error!!! \n To Verify it is you Log in again!! :(\n")
return r
#this is for login
def get_data(usr,password):
while True:
try:
a=db.child("Logininfo").child(usr).get().val()
b=a['username']
c=a['password']
if b == usr:
if c == password:
print("successful")
return 1
break
except:
messagebox.showinfo(title="Username Error",message="It seems u don't have Account!")
break
#this is for verify wheter username already exsited
def check_username(user,passs,email):
while True:
''' try:
a = db.child("Logininfo").child(user).get().val()
b = a['username']
pass
break'''