call LOG.error on obsolete endpoints: /alias/new and /alias/random/new

This commit is contained in:
Son NK 2019-12-08 16:36:35 +01:00
parent f37a155c1f
commit 7f6267cc4a
2 changed files with 12 additions and 1 deletions

View File

@ -12,6 +12,7 @@ from app.models import ApiKey, AliasUsedOn, GenEmail, User, DeletedAlias
from app.utils import random_string
# TODO: obsolete
@api_bp.route("/alias/new", methods=["GET", "POST"])
@cross_origin()
def index():
@ -19,6 +20,8 @@ def index():
the incoming request must provide a valid api-key in "Authentication" header and
the payload must contain "hostname"
"""
LOG.error("/api/alias/new is obsolete!")
api_code = request.headers.get("Authentication")
api_key = ApiKey.get_by(code=api_code)

View File

@ -8,6 +8,7 @@ from app.log import LOG
from app.models import GenEmail, AliasUsedOn
# OBSOLETE
@api_bp.route("/alias/random/new", methods=["POST"])
@cross_origin()
@verify_api_key
@ -21,10 +22,17 @@ def new_random_alias():
409 if alias already exists
"""
LOG.error("/api/alias/new is obsolete! Called by %s", g.user)
user = g.user
if not user.can_create_new_random_alias():
LOG.d("user %s cannot create random alias", user)
return jsonify(error="You have created 3 random aliases, please upgrade to create more"), 400
return (
jsonify(
error="You have created 3 random aliases, please upgrade to create more"
),
400,
)
hostname = request.args.get("hostname")
gen_email = GenEmail.create_new_gen_email(user_id=user.id)