-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathacc.py
123 lines (92 loc) · 3.32 KB
/
acc.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
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
import os
import main
import getpass
import sqlite3
import datetime
from app import app
from time import sleep
from passwordmanager import pwm
def newacc():
os.system('cls')
print ("make a new account?")
conf = input("Y/N: ")
conf = conf.upper()
if (conf == "Y"):
make()
elif (conf == "N"):
main.main()
else:
print("That's not an option")
os.system('cls')
newacc()
def make():
fin = False
while fin != True:
os.system('cls')
print ("Please enter your details.")
email = input("Email: ")
username = input("Username: ")
conn = sqlite3.connect('./database/users.db')
c = conn.cursor()
c.execute("SELECT Username FROM users WHERE Username=?", (username,))
usercheck = str(c.fetchone())
if (usercheck is None):
print ("there are no users in database!!")
password = getpass.getpass("Password: ")
if (len(password) < 5):
print ("Please enter a password that is longer than 5 characters.")
sleep(1)
return
else:
c.execute("INSERT INTO users (Email, Username, Password, Date) VALUES (?, ?, ?, ?)", (email, username, pwm.hash_password(password), datetime.datetime.now()))
conn.commit()
conn.close()
print ("Account successfully created!")
sleep(2)
login()
if (username != usercheck.strip('(').strip(')').strip(',').strip('\'\'')):
password = getpass.getpass("Password: ")
if (len(password) < 5):
print ("Please enter a password that is longer than 5 characters.")
sleep(1)
return
else:
c.execute("INSERT INTO users (Email, Username, Password, Date) VALUES (?, ?, ?, ?)", (email, username, pwm.hash_password(password), datetime.datetime.now()))
conn.commit()
conn.close()
print ("Account successfully created!")
sleep(2)
login()
elif (username == usercheck.strip('(').strip(')').strip(',').strip('\'\'')):
print ("Username already taken")
sleep(1)
make()
else:
print ("Woah..... thats an error")
sleep(1)
return
def login():
fin = False
while fin != True:
os.system('cls')
print ("please enter your account details.")
username = input("Username: ")
password = getpass.getpass("Password: ")
conn = sqlite3.connect('./database/users.db')
c = conn.cursor()
c.execute('SELECT Password FROM users WHERE Username = ?', (username,))
stored_password = str(c.fetchone()).strip('(').strip(')').strip(',').strip('\'\'')
conn.close()
if (pwm.verify_password(stored_password, password) == True):
conn.close()
fin = True
os.system('cls')
print ("Welcome " + username)
sleep(1)
app.app()
else:
print ("Incorrect password.")
print ("input password: " + password)
print (pwm.verify_password(stored_password, password))
print (stored_password)
return