mirror of https://gitlab.com/litecord/litecord.git
fix incorrect http status code for auth routes
This commit is contained in:
parent
29342eb9db
commit
491bdf31df
|
|
@ -44,7 +44,6 @@ def make_token(user_id, user_pwd_hash) -> str:
|
||||||
|
|
||||||
@bp.route('/register', methods=['POST'])
|
@bp.route('/register', methods=['POST'])
|
||||||
async def register():
|
async def register():
|
||||||
"""Register a user on litecord"""
|
|
||||||
j = await request.get_json()
|
j = await request.get_json()
|
||||||
email, password, username = j['email'], j['password'], j['username']
|
email, password, username = j['email'], j['password'], j['username']
|
||||||
|
|
||||||
|
|
@ -68,7 +67,6 @@ async def register():
|
||||||
|
|
||||||
@bp.route('/login', methods=['POST'])
|
@bp.route('/login', methods=['POST'])
|
||||||
async def login():
|
async def login():
|
||||||
"""Login one user into Litecord."""
|
|
||||||
j = await request.get_json()
|
j = await request.get_json()
|
||||||
email, password = j['email'], j['password']
|
email, password = j['email'], j['password']
|
||||||
|
|
||||||
|
|
@ -79,12 +77,12 @@ async def login():
|
||||||
""", email)
|
""", email)
|
||||||
|
|
||||||
if not row:
|
if not row:
|
||||||
return jsonify({'email': ['User not found.']})
|
return jsonify({'email': ['User not found.']}), 401
|
||||||
|
|
||||||
user_id, pwd_hash = row
|
user_id, pwd_hash = row
|
||||||
|
|
||||||
if not await check_password(pwd_hash, password):
|
if not await check_password(pwd_hash, password):
|
||||||
return jsonify({'password': ['Password does not match.']})
|
return jsonify({'password': ['Password does not match.']}), 401
|
||||||
|
|
||||||
return jsonify({
|
return jsonify({
|
||||||
'token': make_token(user_id, pwd_hash)
|
'token': make_token(user_id, pwd_hash)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue