mirror of
https://github.com/simple-login/app.git
synced 2024-11-16 00:48:32 +01:00
always return 200 in /forgot_password
This commit is contained in:
parent
f8f501b84d
commit
e81b807971
3 changed files with 9 additions and 13 deletions
|
@ -819,9 +819,7 @@ Output:
|
|||
Input:
|
||||
- email
|
||||
|
||||
Output:
|
||||
- 200: user is going to receive an email to reset the password
|
||||
- 400 if error (email not found)
|
||||
Output: always return 200, even if email doesn't exist. User need to enter correctly their email.
|
||||
|
||||
#### GET /api/aliases
|
||||
|
||||
|
|
|
@ -332,16 +332,14 @@ def forgot_password():
|
|||
|
||||
"""
|
||||
data = request.get_json()
|
||||
if not data:
|
||||
return jsonify(error="request body cannot be empty"), 400
|
||||
if not data or not data.get("email"):
|
||||
return jsonify(error="request body must contain email"), 400
|
||||
|
||||
email = data.get("email")
|
||||
email = data.get("email").lower()
|
||||
|
||||
user = User.get_by(email=email)
|
||||
|
||||
if not user:
|
||||
return jsonify(error="Email not found"), 400
|
||||
if user:
|
||||
send_reset_password_email(user)
|
||||
|
||||
send_reset_password_email(user)
|
||||
|
||||
return jsonify(reset_sent=True)
|
||||
return jsonify(ok=True)
|
||||
|
|
|
@ -210,9 +210,9 @@ def test_auth_login_forgot_password(flask_client):
|
|||
|
||||
assert r.status_code == 200
|
||||
|
||||
# No such email
|
||||
# No such email, still return 200
|
||||
r = flask_client.post(
|
||||
url_for("api.forgot_password"), json={"email": "not-exist@b.c"},
|
||||
)
|
||||
|
||||
assert r.status_code == 400
|
||||
assert r.status_code == 200
|
||||
|
|
Loading…
Reference in a new issue