diff --git a/README.md b/README.md index 106de242..7c7b2113 100644 --- a/README.md +++ b/README.md @@ -649,8 +649,9 @@ Output: if api key is correct, return a json with user name and whether user is ```json { - "name": "John Wick", - "is_premium": false + "name": "John Wick", + "is_premium": false, + "email": "john@wick.com" } ``` diff --git a/app/api/views/user_info.py b/app/api/views/user_info.py index 2b25745f..318b418a 100644 --- a/app/api/views/user_info.py +++ b/app/api/views/user_info.py @@ -1,13 +1,7 @@ -from flask import jsonify, request, g +from flask import jsonify, g from flask_cors import cross_origin -from sqlalchemy import desc from app.api.base import api_bp, verify_api_key -from app.config import EMAIL_DOMAIN -from app.extensions import db -from app.log import LOG -from app.models import AliasUsedOn, Alias, User -from app.utils import convert_to_id, random_word @api_bp.route("/user_info") @@ -19,4 +13,6 @@ def user_info(): """ user = g.user - return jsonify({"name": user.name, "is_premium": user.is_premium()}) + return jsonify( + {"name": user.name, "is_premium": user.is_premium(), "email": user.email} + ) diff --git a/tests/api/test_user_info.py b/tests/api/test_user_info.py index c40d23a6..5c4c404f 100644 --- a/tests/api/test_user_info.py +++ b/tests/api/test_user_info.py @@ -19,7 +19,7 @@ def test_user_in_trial(flask_client): ) assert r.status_code == 200 - assert r.json == {"is_premium": True, "name": "Test User"} + assert r.json == {"is_premium": True, "name": "Test User", "email": "a@b.c"} def test_wrong_api_key(flask_client):