Просмотр исходного кода

use null instead of "" in /api/auth/login

Son NK 5 лет назад
Родитель
Сommit
c7903d534a
2 измененных файлов с 4 добавлено и 4 удалено
  1. 2 2
      app/api/views/auth_login.py
  2. 2 2
      tests/api/test_auth_login.py

+ 2 - 2
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

+ 2 - 2
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"