From 0002531bc05875851bc33ebab331f1492cf1e75a Mon Sep 17 00:00:00 2001 From: Son NK <> Date: Tue, 9 Jun 2020 17:19:03 +0200 Subject: [PATCH] return user email in /api/auth/login --- README.md | 1 + app/api/views/auth.py | 2 +- tests/api/test_auth_login.py | 1 + 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index efdb1bc1..e8367026 100644 --- a/README.md +++ b/README.md @@ -695,6 +695,7 @@ Input: Output: - name: user name, could be an empty string +- email: user email - mfa_enabled: boolean - mfa_key: only useful when user enables MFA. In this case, user needs to enter their OTP token in order to login. - api_key: if MFA is not enabled, the `api key` is returned right away. diff --git a/app/api/views/auth.py b/app/api/views/auth.py index 2fa1adb4..280f71c9 100644 --- a/app/api/views/auth.py +++ b/app/api/views/auth.py @@ -323,7 +323,7 @@ def auth_google(): def auth_payload(user, device) -> dict: - ret = {"name": user.name, "mfa_enabled": user.enable_otp} + ret = {"name": user.name, "email": user.email, "mfa_enabled": user.enable_otp} # do not give api_key, user can only obtain api_key after OTP verification if user.enable_otp: diff --git a/tests/api/test_auth_login.py b/tests/api/test_auth_login.py index 0bd6ca7e..5724b0f9 100644 --- a/tests/api/test_auth_login.py +++ b/tests/api/test_auth_login.py @@ -21,6 +21,7 @@ def test_auth_login_success_mfa_disabled(flask_client): assert r.status_code == 200 assert r.json["api_key"] + assert r.json["email"] assert r.json["mfa_enabled"] == False assert r.json["mfa_key"] is None assert r.json["name"] == "Test User"