diff --git a/SWSCloudAPI/Utils/decorators.py b/SWSCloudAPI/Utils/decorators.py index 344a9b0..4162224 100644 --- a/SWSCloudAPI/Utils/decorators.py +++ b/SWSCloudAPI/Utils/decorators.py @@ -14,7 +14,7 @@ def login_required(f): if not validators.email(request.json.get('email')): return jsonify(status='error', message='invalid email format') # verify email/password - if not Users.auth(request.json.get('email'), request.json.get('password')): + if not Users.auth(request.json.get('email'), request.json.get('password').encode()): return jsonify(status='error', message='invalid auth') # return f(*args, **kwargs) diff --git a/SWSCloudCore/controllers/users/__init__.py b/SWSCloudCore/controllers/users/__init__.py index 4effd6b..44d717a 100644 --- a/SWSCloudCore/controllers/users/__init__.py +++ b/SWSCloudCore/controllers/users/__init__.py @@ -36,7 +36,7 @@ class ControllerUsers: def update(self, user_id, **kwargs): if 'password' in kwargs: x = models.Users.update( - password=md5(kwargs['password']).hexdigest() + password=md5(kwargs['password'].encode()).hexdigest() ).where( models.Users.id == user_id ) @@ -69,7 +69,7 @@ class ControllerUsers: :param password: :return: """ - password_hash = md5(password).hexdigest() + password_hash = md5(password.encode()).hexdigest() result = models.Users.select().where( models.Users.email == email, models.Users.password == password_hash, @@ -86,7 +86,7 @@ class ControllerUsers: :param password: :return: """ - password_hash = md5(password).hexdigest() + password_hash = md5(password.encode()).hexdigest() user_id = uuid.uuid4() # TODO: add date registration and update of date - =datetime.datetime.now() user = models.Users.create(id=user_id, email=email, password=password_hash, status=1) @@ -95,7 +95,7 @@ class ControllerUsers: return False def password_update(self, user_id, password): - password_hash = md5(password).hexdigest() + password_hash = md5(password.encode()).hexdigest() u = models.Users.get(models.Users.id == user_id) u.password = password_hash u.save() diff --git a/SWSCloudWeb/common.py b/SWSCloudWeb/common.py index d42f058..d6364a5 100644 --- a/SWSCloudWeb/common.py +++ b/SWSCloudWeb/common.py @@ -16,7 +16,7 @@ def requires_login(f): else: return redirect(url_for("account.logout")) - if not Users.auth(session.get('email'), session.get('password'), 1): + if not Users.auth(session.get('email'), session.get('password').encode(), 1): return redirect(url_for("account.logout")) return f(*args, **kwargs)