-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathRegistration
134 lines (104 loc) · 4.02 KB
/
Registration
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
from tkinter import *
import tkinter.messagebox as tm
from Popup import *
import Users
import re
import sqlite3
import hashlib
import bcrypt
db = sqlite3.connect('game nebula.db')
c = db.cursor()
class RegistrationFrame(Frame):
def __init__(self, master):
Frame.__init__(self, master)
self.master = master
self.regUI()
def regUI(self):
self.master.title("Registration")
self.pack(fill=BOTH, expand=True)
root.resizable(width=FALSE, height=FALSE)
frame1 = Frame(self)
frame1.pack(fill=X)
frame2 = Frame(self)
frame2.pack(fill=X)
frame3 = Frame(self)
frame3.pack(fill=X)
frame4 = Frame(self)
frame4.pack(fill=X)
frame5 = Frame(self)
frame5.pack(fill=X)
frame6 = Frame(self)
frame6.pack(fill=X)
self.UserLabel = Label(frame1, text="Enter username")
self.UserLabel.pack(side=LEFT, padx=5, pady=5)
self.PassLabel = Label(frame2, text="Enter Password")
self.PassLabel.pack(side=LEFT, padx=5, pady=5)
self.PassReLabel = Label(frame3, text="Re-Enter Password")
self.PassReLabel.pack(side=LEFT, padx=5, pady=5)
self.EmailLabel = Label(frame4, text="Enter email")
self.EmailLabel.pack(side=LEFT, padx=5, pady=5)
self.UserEntry = Entry(frame1, borderwidth=2)
self.UserEntry.pack(side=LEFT, padx=20)
self.PassEntry = Entry(frame2, show="*", borderwidth=2)
self.PassEntry.pack(side=LEFT, padx=22)
self.PassReEntry = Entry(frame3, show="*", borderwidth=2)
self.PassReEntry.pack(side=LEFT, padx=5)
self.EmailEntry = Entry(frame4, borderwidth=2)
self.EmailEntry.pack(side=LEFT, padx=43)
self.adminLabel = Label(frame1, text="Admin Code*")
self.adminLabel.pack(side=LEFT, padx=30)
self.adminEntry = Entry(frame2, show="*", borderwidth=2)
self.adminEntry.pack(side=LEFT, padx=10)
self.regbtn = Button(frame6, text="Register", fg='green', command = self._registration_btn_clicked)
self.regbtn.pack(side=BOTTOM)
def _registration_btn_clicked(self):
username = self.UserEntry.get()
password = self.PassEntry.get()
passwordRe = self.PassReEntry.get()
email = self.EmailEntry.get()
adminCode = "makemeadmin"
adminEntry = self.adminEntry.get()
permission = 0
banned = 0
logged = 0
credits = 30
if len(self.UserEntry.get()) == 0 or len(self.PassEntry.get()) == 0\
or len(self.PassReEntry.get()) == 0 or len(self.EmailEntry.get()) == 0 :
pu.onNull()
elif len(username) > 14 or len(username) < 4 :
pu.onUserLength()
elif len(password) > 14 or len(password) < 4:
pu.onPassLength()
elif not re.match("^[0-z]*$", username) or not re.match("^[0-z]*$", password):
pu.onSpecialChar()
else:
def CheckRegExists(username):
c.execute("SELECT name FROM UserData WHERE name=?", (username,))
data = c.fetchall()
if not data:
return False
else:
return True
if adminEntry == adminCode:
permission = 1
else:
permission = 0
if CheckRegExists(username) == True:
pu.onUserAvail()
else:
if password != passwordRe:
pu.onPasswordMatch()
else:
pu.onReg()
c.execute('INSERT INTO UserData VALUES (?,?,?,?,?,?,?)', (username, password, email, permission, banned, logged, credits))
Users.create_user(username, password, permission)
db.commit()
db.close()
root.destroy()
root = Tk()
def on_closing():
root.withdraw()
root.protocol("WM_DELETE_WINDOW", on_closing)
pu = Popup(parent=root)
ft = RegistrationFrame(master=root)
root.mainloop()