From c7903d534a0caaf900c18f4069ad22164160fe1d Mon Sep 17 00:00:00 2001 From: Son NK Date: Tue, 4 Feb 2020 18:32:57 +0700 Subject: [PATCH] use null instead of "" in /api/auth/login --- app/api/views/auth_login.py | 4 ++-- tests/api/test_auth_login.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/api/views/auth_login.py b/app/api/views/auth_login.py index 173bb5eb..c4bce079 100644 --- a/app/api/views/auth_login.py +++ b/app/api/views/auth_login.py @@ -54,11 +54,11 @@ def auth_login(): if user.enable_otp: s = Signer(FLASK_SECRET) ret["mfa_key"] = s.sign(str(user.id)) - ret["api_key"] = "" + ret["api_key"] = None else: api_key = ApiKey.create(user.id, device) db.session.commit() - ret["mfa_key"] = "" + ret["mfa_key"] = None ret["api_key"] = api_key.code return jsonify(**ret), 200 diff --git a/tests/api/test_auth_login.py b/tests/api/test_auth_login.py index 0dbfb4a3..59f89024 100644 --- a/tests/api/test_auth_login.py +++ b/tests/api/test_auth_login.py @@ -16,7 +16,7 @@ def test_auth_login_success_mfa_disabled(flask_client): assert r.status_code == 200 assert r.json["api_key"] assert r.json["mfa_enabled"] == False - assert r.json["mfa_key"] == "" + assert r.json["mfa_key"] is None assert r.json["name"] == "Test User" @@ -36,7 +36,7 @@ def test_auth_login_success_mfa_enabled(flask_client): ) assert r.status_code == 200 - assert r.json["api_key"] == "" + assert r.json["api_key"] is None assert r.json["mfa_enabled"] == True assert r.json["mfa_key"] assert r.json["name"] == "Test User"