Skip to content
Snippets Groups Projects
Commit 24dfdd13 authored by Eirik Martin Danielsen's avatar Eirik Martin Danielsen :speech_balloon:
Browse files

check for email in update email

parent 82302d1a
No related branches found
No related tags found
1 merge request!38Resolve "remove dead code and cleanup"
......@@ -67,9 +67,13 @@ class UserEndpoint(Resource):
if 'newEmail' in data:
user_check = db.session.query(User).filter_by(email=data['newEmail']).first()
if user_check is None and re.search(EMAIL_REGEX, data['newEmail'].lower()):
valid = validate_email(data.email.data.lower(), verify=True,check_mx=True)
if valid:
user.email = data['newEmail'].lower()
db.session.commit()
return jsonify({"message": "email was updated", "status": 200})
else:
return jsonify({"message": "email doesn't exist", 'status': 400})
else:
return jsonify({"message": "invalid email", "status": 400})
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment