Spaces:
Runtime error
Runtime error
IsaacKerson
commited on
Commit
•
0c707fa
1
Parent(s):
94e5d01
get added get_hashed_password function to auth
Browse files- authenticator.py +8 -2
authenticator.py
CHANGED
@@ -104,7 +104,7 @@ class Authenticate:
|
|
104 |
|
105 |
def check_username(self):
|
106 |
usernames = []
|
107 |
-
query =
|
108 |
c = self.get_cursor()
|
109 |
for item in c.execute(query, self.dbtable):
|
110 |
usernames.append(item[0])
|
@@ -112,6 +112,12 @@ class Authenticate:
|
|
112 |
return True
|
113 |
else:
|
114 |
return False
|
|
|
|
|
|
|
|
|
|
|
|
|
115 |
|
116 |
def token_encode(self):
|
117 |
"""
|
@@ -152,7 +158,7 @@ class Authenticate:
|
|
152 |
boolean
|
153 |
The validation state for the input password by comparing it to the hashed password on disk.
|
154 |
"""
|
155 |
-
return bcrypt.checkpw(self.password.encode(), self.
|
156 |
|
157 |
def login(self, form_name, location='main'):
|
158 |
"""Create a new instance of "authenticate".
|
|
|
104 |
|
105 |
def check_username(self):
|
106 |
usernames = []
|
107 |
+
query = "SELECT username FROM ?"
|
108 |
c = self.get_cursor()
|
109 |
for item in c.execute(query, self.dbtable):
|
110 |
usernames.append(item[0])
|
|
|
112 |
return True
|
113 |
else:
|
114 |
return False
|
115 |
+
|
116 |
+
def get_hashed_password(self):
|
117 |
+
query = "SELECT hashed_password FROM ? WHERE username = ?"
|
118 |
+
c = self.get_cursor()
|
119 |
+
c.execute(query, (self.dbtable, self.username)
|
120 |
+
return c.fetchone()[0]
|
121 |
|
122 |
def token_encode(self):
|
123 |
"""
|
|
|
158 |
boolean
|
159 |
The validation state for the input password by comparing it to the hashed password on disk.
|
160 |
"""
|
161 |
+
return bcrypt.checkpw(self.password.encode(), self.get_hashed_password().encode())
|
162 |
|
163 |
def login(self, form_name, location='main'):
|
164 |
"""Create a new instance of "authenticate".
|