aboutsummaryrefslogtreecommitdiff
path: root/src/web/controllers/user.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/web/controllers/user.py')
-rw-r--r--src/web/controllers/user.py12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/web/controllers/user.py b/src/web/controllers/user.py
index ae169b05..1b5c123e 100644
--- a/src/web/controllers/user.py
+++ b/src/web/controllers/user.py
@@ -1,9 +1,10 @@
-import random
-import hashlib
-from werkzeug import generate_password_hash
+import logging
+from werkzeug import generate_password_hash, check_password_hash
from .abstract import AbstractController
from web.models import User
+logger = logging.getLogger(__name__)
+
class UserController(AbstractController):
_db_cls = User
@@ -11,10 +12,13 @@ class UserController(AbstractController):
def _handle_password(self, attrs):
if attrs.get('password'):
- attrs['pwdhash'] = generate_password_hash(attrs.pop('password'))
+ attrs['password'] = generate_password_hash(attrs.pop('password'))
elif 'password' in attrs:
del attrs['password']
+ def check_password(self, user, password):
+ return check_password_hash(user.pwdhash, password)
+
def create(self, **attrs):
self._handle_password(attrs)
return super().create(**attrs)
bgstack15