summaryrefslogtreecommitdiff
path: root/docs/tutorials/wiki2/src
diff options
context:
space:
mode:
Diffstat (limited to 'docs/tutorials/wiki2/src')
-rw-r--r--docs/tutorials/wiki2/src/authentication/tutorial/models/user.py5
1 files changed, 3 insertions, 2 deletions
diff --git a/docs/tutorials/wiki2/src/authentication/tutorial/models/user.py b/docs/tutorials/wiki2/src/authentication/tutorial/models/user.py
index 6fb32a1b2..6499491b2 100644
--- a/docs/tutorials/wiki2/src/authentication/tutorial/models/user.py
+++ b/docs/tutorials/wiki2/src/authentication/tutorial/models/user.py
@@ -1,4 +1,5 @@
import bcrypt
+import hmac
from sqlalchemy import (
Column,
Integer,
@@ -23,7 +24,7 @@ class User(Base):
def check_password(self, pw):
if self.password_hash is not None:
- expected_hash = self.password_hash.encode('utf8')
+ expected_hash = self.password_hash
actual_hash = bcrypt.hashpw(pw.encode('utf8'), expected_hash)
- return expected_hash == actual_hash
+ return hmac.compare_digest(expected_hash, actual_hash)
return False