Browse Source

return user email in /api/auth/mfa

Son NK 5 năm trước cách đây
mục cha
commit
dfe708b4fb
3 tập tin đã thay đổi với 5 bổ sung2 xóa
  1. 1 0
      README.md
  2. 3 2
      app/api/views/auth_mfa.py
  3. 1 0
      tests/api/test_auth_mfa.py

+ 1 - 0
README.md

@@ -715,6 +715,7 @@ Input:
 Output:
 - name: user name, could be an empty string
 - api_key: if MFA is not enabled, the `api key` is returned right away.
+- email: user email
 
 The `api_key` is used in all subsequent requests. It's empty if MFA is enabled.
 If user hasn't enabled MFA, `mfa_key` is empty.

+ 3 - 2
app/api/views/auth_mfa.py

@@ -23,7 +23,8 @@ def auth_mfa():
         200 and user info containing:
         {
             name: "John Wick",
-            api_key: "a long string"
+            api_key: "a long string",
+            email: "user email"
         }
 
     """
@@ -55,7 +56,7 @@ def auth_mfa():
     if not totp.verify(mfa_token):
         return jsonify(error="Wrong TOTP Token"), 400
 
-    ret = {"name": user.name}
+    ret = {"name": user.name, "email": user.email}
 
     api_key = ApiKey.get_by(user_id=user.id, name=device)
     if not api_key:

+ 1 - 0
tests/api/test_auth_mfa.py

@@ -29,6 +29,7 @@ def test_auth_mfa_success(flask_client):
 
     assert r.status_code == 200
     assert r.json["api_key"]
+    assert r.json["email"]
     assert r.json["name"] == "Test User"