Browse Source

fix(login): fix bugs

master
kdxcxs 4 years ago
parent
commit
4e72feeee9
  1. 4
      app.py
  2. 2
      dao.py

4
app.py

@ -16,7 +16,9 @@ def login():
username = rdata['username']
password = rdata['password']
if dao.valid(username, password):
return make_response(json.dumps({'result': 'success'})).set_cookie('jwt', jwt.generate_jwt(username))
response = make_response(json.dumps({'result': 'success'}))
response.set_cookie('jwt', jwt.generate_jwt(username))
return response
else:
return make_response(json.dumps({'result': 'fail'}))

2
dao.py

@ -6,7 +6,7 @@ def valid(username, password):
base_cursor = db_connection.cursor()
password_cursor = base_cursor.execute(f'SELECT password FROM user WHERE username=="{username}";')
db_password = password_cursor.fetchone()
if len(db_password != 1):
if db_password is None:
return False
if db_password[0] == password:
return True

Loading…
Cancel
Save