#1 fix
This commit is contained in:
parent
fceb922d94
commit
c7286dc164
3 changed files with 6 additions and 6 deletions
|
@ -14,7 +14,7 @@ def login_required(f):
|
||||||
if not validators.email(request.json.get('email')):
|
if not validators.email(request.json.get('email')):
|
||||||
return jsonify(status='error', message='invalid email format')
|
return jsonify(status='error', message='invalid email format')
|
||||||
# verify email/password
|
# 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 jsonify(status='error', message='invalid auth')
|
||||||
#
|
#
|
||||||
return f(*args, **kwargs)
|
return f(*args, **kwargs)
|
||||||
|
|
|
@ -36,7 +36,7 @@ class ControllerUsers:
|
||||||
def update(self, user_id, **kwargs):
|
def update(self, user_id, **kwargs):
|
||||||
if 'password' in kwargs:
|
if 'password' in kwargs:
|
||||||
x = models.Users.update(
|
x = models.Users.update(
|
||||||
password=md5(kwargs['password']).hexdigest()
|
password=md5(kwargs['password'].encode()).hexdigest()
|
||||||
).where(
|
).where(
|
||||||
models.Users.id == user_id
|
models.Users.id == user_id
|
||||||
)
|
)
|
||||||
|
@ -69,7 +69,7 @@ class ControllerUsers:
|
||||||
:param password:
|
:param password:
|
||||||
:return:
|
:return:
|
||||||
"""
|
"""
|
||||||
password_hash = md5(password).hexdigest()
|
password_hash = md5(password.encode()).hexdigest()
|
||||||
result = models.Users.select().where(
|
result = models.Users.select().where(
|
||||||
models.Users.email == email,
|
models.Users.email == email,
|
||||||
models.Users.password == password_hash,
|
models.Users.password == password_hash,
|
||||||
|
@ -86,7 +86,7 @@ class ControllerUsers:
|
||||||
:param password:
|
:param password:
|
||||||
:return:
|
:return:
|
||||||
"""
|
"""
|
||||||
password_hash = md5(password).hexdigest()
|
password_hash = md5(password.encode()).hexdigest()
|
||||||
user_id = uuid.uuid4()
|
user_id = uuid.uuid4()
|
||||||
# TODO: add date registration and update of date - =datetime.datetime.now()
|
# 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)
|
user = models.Users.create(id=user_id, email=email, password=password_hash, status=1)
|
||||||
|
@ -95,7 +95,7 @@ class ControllerUsers:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def password_update(self, user_id, password):
|
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 = models.Users.get(models.Users.id == user_id)
|
||||||
u.password = password_hash
|
u.password = password_hash
|
||||||
u.save()
|
u.save()
|
||||||
|
|
|
@ -16,7 +16,7 @@ def requires_login(f):
|
||||||
else:
|
else:
|
||||||
return redirect(url_for("account.logout"))
|
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 redirect(url_for("account.logout"))
|
||||||
|
|
||||||
return f(*args, **kwargs)
|
return f(*args, **kwargs)
|
||||||
|
|
Loading…
Add table
Reference in a new issue