-
Notifications
You must be signed in to change notification settings - Fork 1
/
password_login.py
90 lines (73 loc) · 2.85 KB
/
password_login.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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
from swampy.Gui import *
from getpass import *
import pymongo
from pymongo import MongoClient
def main():
client = MongoClient()
db = client.test_database
users = db.users
users.remove()
print users
users.insert({'user':'hey', 'password':'there'})
for thing in users.find():
print thing
def newusergui():
def close():
signupgui.quit()
def newuser():
for user in users.find():
for info in user:
print info
print user[info]
if user[info]==newusername.get():
print 'already in use'
label.config(text="That username is already in use.")
return
if newpassword.get()==repeatnewpassword.get():
print 'running this loop'
users.insert({'user':newusername.get(), 'password': newpassword.get()})
print users
label.config(text="Thank you for signing up!")
close()
launch()
return True
else:
label.config(text="Your passwords don't match! Please try again")
usernamelabel=signupgui.la(text='Username:')
newusername=signupgui.en()
newpasswordlabel=signupgui.la(text='Password:')
newpassword=signupgui.en(show='*')
repeatpasswordlabel=signupgui.la(text='Re-enter Password')
repeatnewpassword=signupgui.en(show='*')
button=signupgui.bu(text="Let's get started!",command=newuser)
label=signupgui.la()
def logingui():
def close():
for user in users.find():
for info in user:
if password.get()==user[info]:
label.config(text= "You are now logged in!")
signupgui.quit()
launch()
return True
else:
label.config(text= "We do not recognize your username or password, please try again.")
usernamelabel=signupgui.la(text = "MusicSwAPPer Username: ")
username = signupgui.en()
passwordlabel=signupgui.la("MusicSwAPPer Password: ")
password = signupgui.en(show = '*')
button=signupgui.bu(text="Let's get started!",command=close)
label=signupgui.la()
signupgui=Gui()
signupgui.title('MusicSwAPPer Sign Up')
signuporlogin = signupgui.la(text = 'Please Sign-In or Sign-Up!')
signupgui.row()
login = signupgui.bu(text = 'Sign in', command=logingui)
sign = signupgui.bu(text = 'Sign up', command=newusergui)
signupgui.endrow()
signupgui.mainloop()
def launch():
g = Gui()
g.mainloop()
if __name__ == '__main__' :
main()