prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
   Verify Email endpoint doesn’t work.
  **I'm submitting a ...**  (check one with "x")
  - [X] bug report
  - [ ] feature request
  - [ ] support request => Please do not submit support requests here, instead ask your query in out Gitter channel at https://gitter.im/fossasia/open-event-orga-server
  
  There are two specific errors in the function.
  - [x] Firstly the email verification state change isn’t saved in db
  - [x] Response for the view function is missing.
  
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `app/api/auth.py`
  Content:
  ```
  1 import base64
  2 from flask import request, jsonify, abort, make_response, Blueprint
  3 from flask_jwt import current_identity as current_user, jwt_required
  4 from sqlalchemy.orm.exc import NoResultFound
  5 
  6 from app import get_settings
  7 from app.api.helpers.db import save_to_db
  8 from app.api.helpers.files import make_frontend_url
  9 from app.api.helpers.mail import send_email_with_action
  10 
  11 from app.api.helpers.utilities import get_serializer
  12 from app.models.mail import PASSWORD_RESET
  13 from app.models.user import User
  14 
  15 auth_routes = Blueprint('auth', __name__, url_prefix='/v1/auth')
  16 
  17 
  18 @auth_routes.route('/verify-email', methods=['POST'])
  19 def verify_email():
  20     token = base64.b64decode(request.json['data']['token'])
  21     s = get_serializer()
  22 
  23     try:
  24         data = s.loads(token)
  25     except Exception:
  26         return abort(
  27             make_response(jsonify(error="Invalid Token"), 400)
  28         )
  29 
  30     try:
  31         user = User.query.filter_by(email=data[0]).one()
  32     except Exception:
  33         return abort(
  34             make_response(jsonify(error="Invalid Token"), 400)
  35         )
  36     else:
  37         user.is_verified = True
  38 
  39 
  40 @auth_routes.route('/reset-password', methods=['POST'])
  41 def reset_password_post():
  42     email = request.json['data']['email']
  43 
  44     try:
  45         user = User.query.filter_by(email=email).one()
  46     except NoResultFound:
  47         return abort(
  48             make_response(jsonify(error="User not found"), 404)
  49         )
  50     else:
  51         link = make_frontend_url('/reset-password', {'token': user.reset_password})
  52         send_email_with_action(user, PASSWORD_RESET, app_name=get_settings()['app_name'], link=link)
  53 
  54     return make_response(jsonify(message="Email Sent"), 200)
  55 
  56 
  57 @auth_routes.route('/reset-password', methods=['PATCH'])
  58 def reset_password_patch():
  59     token = request.json['data']['token']
  60     password = request.json['data']['password']
  61 
  62     try:
  63         user = User.query.filter_by(reset_password=token).one()
  64     except NoResultFound:
  65         return abort(
  66             make_response(jsonify(error="User not found"), 404)
  67         )
  68     else:
  69         user.password = password
  70         save_to_db(user)
  71 
  72     return jsonify({
  73         "id": user.id,
  74         "email": user.email,
  75         "name": user.name if user.get('name') else None
  76     })
  77 
  78 
  79 @auth_routes.route('/change-password', methods=['POST'])
  80 @jwt_required()
  81 def change_password():
  82     old_password = request.json['data']['old-password']
  83     new_password = request.json['data']['new-password']
  84 
  85     try:
  86         user = User.query.filter_by(id=current_user.id).one()
  87     except NoResultFound:
  88         return abort(
  89             make_response(jsonify(error="User not found"), 404)
  90         )
  91     else:
  92         if user.is_correct_password(old_password):
  93 
  94             user.password = new_password
  95             save_to_db(user)
  96         else:
  97             return make_response(jsonify(error="Wrong Password"), 400)
  98 
  99     return jsonify({
  100         "id": user.id,
  101         "email": user.email,
  102         "name": user.fullname if user.fullname else None,
  103         "password_changed": True
  104     })
  105
  ```
  --- END FILES ---
  
  Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.
  
  Here is an example:
  
  ```diff
  diff --git a/examples/server_async.py b/examples/server_async.py
  --- a/examples/server_async.py
  +++ b/examples/server_async.py
  @@ -313,4 +313,4 @@
   
   
   if __name__ == "__main__":
  -    asyncio.run(run_async_server("."), debug=True)
  +    asyncio.run(run_async_server(), debug=True)
  diff --git a/examples/server_sync.py b/examples/server_sync.py
  --- a/examples/server_sync.py
  +++ b/examples/server_sync.py
  @@ -313,5 +313,5 @@
   
   
   if __name__ == "__main__":
  -    server = run_sync_server(".")
  +    server = run_sync_server()
       server.shutdown()
  
  ```
  
golden_diff: diff --git a/app/api/auth.py b/app/api/auth.py
  --- a/app/api/auth.py
  +++ b/app/api/auth.py
  @@ -35,6 +35,8 @@
           )
       else:
           user.is_verified = True
  +        save_to_db(user)
  +        return make_response(jsonify(message="Email Verified"), 200)
   
   
   @auth_routes.route('/reset-password', methods=['POST'])
  @@ -94,7 +96,9 @@
               user.password = new_password
               save_to_db(user)
           else:
  -            return make_response(jsonify(error="Wrong Password"), 400)
  +            return abort(
  +                make_response(jsonify(error="Wrong Password"), 400)
  +            )
   
       return jsonify({
           "id": user.id,
  
verification_info: {"golden_diff": "diff --git a/app/api/auth.py b/app/api/auth.py\n--- a/app/api/auth.py\n+++ b/app/api/auth.py\n@@ -35,6 +35,8 @@\n         )\n     else:\n         user.is_verified = True\n+        save_to_db(user)\n+        return make_response(jsonify(message=\"Email Verified\"), 200)\n \n \n @auth_routes.route('/reset-password', methods=['POST'])\n@@ -94,7 +96,9 @@\n             user.password = new_password\n             save_to_db(user)\n         else:\n-            return make_response(jsonify(error=\"Wrong Password\"), 400)\n+            return abort(\n+                make_response(jsonify(error=\"Wrong Password\"), 400)\n+            )\n \n     return jsonify({\n         \"id\": user.id,\n", "issue": " Verify Email endpoint doesn\u2019t work.\n**I'm submitting a ...**  (check one with \"x\")\r\n- [X] bug report\r\n- [ ] feature request\r\n- [ ] support request => Please do not submit support requests here, instead ask your query in out Gitter channel at https://gitter.im/fossasia/open-event-orga-server\r\n\r\nThere are two specific errors in the function.\r\n- [x] Firstly the email verification state change isn\u2019t saved in db\r\n- [x] Response for the view function is missing.\r\n\n", "before_files": [{"content": "import base64\nfrom flask import request, jsonify, abort, make_response, Blueprint\nfrom flask_jwt import current_identity as current_user, jwt_required\nfrom sqlalchemy.orm.exc import NoResultFound\n\nfrom app import get_settings\nfrom app.api.helpers.db import save_to_db\nfrom app.api.helpers.files import make_frontend_url\nfrom app.api.helpers.mail import send_email_with_action\n\nfrom app.api.helpers.utilities import get_serializer\nfrom app.models.mail import PASSWORD_RESET\nfrom app.models.user import User\n\nauth_routes = Blueprint('auth', __name__, url_prefix='/v1/auth')\n\n\n@auth_routes.route('/verify-email', methods=['POST'])\ndef verify_email():\n    token = base64.b64decode(request.json['data']['token'])\n    s = get_serializer()\n\n    try:\n        data = s.loads(token)\n    except Exception:\n        return abort(\n            make_response(jsonify(error=\"Invalid Token\"), 400)\n        )\n\n    try:\n        user = User.query.filter_by(email=data[0]).one()\n    except Exception:\n        return abort(\n            make_response(jsonify(error=\"Invalid Token\"), 400)\n        )\n    else:\n        user.is_verified = True\n\n\n@auth_routes.route('/reset-password', methods=['POST'])\ndef reset_password_post():\n    email = request.json['data']['email']\n\n    try:\n        user = User.query.filter_by(email=email).one()\n    except NoResultFound:\n        return abort(\n            make_response(jsonify(error=\"User not found\"), 404)\n        )\n    else:\n        link = make_frontend_url('/reset-password', {'token': user.reset_password})\n        send_email_with_action(user, PASSWORD_RESET, app_name=get_settings()['app_name'], link=link)\n\n    return make_response(jsonify(message=\"Email Sent\"), 200)\n\n\n@auth_routes.route('/reset-password', methods=['PATCH'])\ndef reset_password_patch():\n    token = request.json['data']['token']\n    password = request.json['data']['password']\n\n    try:\n        user = User.query.filter_by(reset_password=token).one()\n    except NoResultFound:\n        return abort(\n            make_response(jsonify(error=\"User not found\"), 404)\n        )\n    else:\n        user.password = password\n        save_to_db(user)\n\n    return jsonify({\n        \"id\": user.id,\n        \"email\": user.email,\n        \"name\": user.name if user.get('name') else None\n    })\n\n\n@auth_routes.route('/change-password', methods=['POST'])\n@jwt_required()\ndef change_password():\n    old_password = request.json['data']['old-password']\n    new_password = request.json['data']['new-password']\n\n    try:\n        user = User.query.filter_by(id=current_user.id).one()\n    except NoResultFound:\n        return abort(\n            make_response(jsonify(error=\"User not found\"), 404)\n        )\n    else:\n        if user.is_correct_password(old_password):\n\n            user.password = new_password\n            save_to_db(user)\n        else:\n            return make_response(jsonify(error=\"Wrong Password\"), 400)\n\n    return jsonify({\n        \"id\": user.id,\n        \"email\": user.email,\n        \"name\": user.fullname if user.fullname else None,\n        \"password_changed\": True\n    })\n", "path": "app/api/auth.py"}], "after_files": [{"content": "import base64\nfrom flask import request, jsonify, abort, make_response, Blueprint\nfrom flask_jwt import current_identity as current_user, jwt_required\nfrom sqlalchemy.orm.exc import NoResultFound\n\nfrom app import get_settings\nfrom app.api.helpers.db import save_to_db\nfrom app.api.helpers.files import make_frontend_url\nfrom app.api.helpers.mail import send_email_with_action\n\nfrom app.api.helpers.utilities import get_serializer\nfrom app.models.mail import PASSWORD_RESET\nfrom app.models.user import User\n\nauth_routes = Blueprint('auth', __name__, url_prefix='/v1/auth')\n\n\n@auth_routes.route('/verify-email', methods=['POST'])\ndef verify_email():\n    token = base64.b64decode(request.json['data']['token'])\n    s = get_serializer()\n\n    try:\n        data = s.loads(token)\n    except Exception:\n        return abort(\n            make_response(jsonify(error=\"Invalid Token\"), 400)\n        )\n\n    try:\n        user = User.query.filter_by(email=data[0]).one()\n    except Exception:\n        return abort(\n            make_response(jsonify(error=\"Invalid Token\"), 400)\n        )\n    else:\n        user.is_verified = True\n        save_to_db(user)\n        return make_response(jsonify(message=\"Email Verified\"), 200)\n\n\n@auth_routes.route('/reset-password', methods=['POST'])\ndef reset_password_post():\n    email = request.json['data']['email']\n\n    try:\n        user = User.query.filter_by(email=email).one()\n    except NoResultFound:\n        return abort(\n            make_response(jsonify(error=\"User not found\"), 404)\n        )\n    else:\n        link = make_frontend_url('/reset-password', {'token': user.reset_password})\n        send_email_with_action(user, PASSWORD_RESET, app_name=get_settings()['app_name'], link=link)\n\n    return make_response(jsonify(message=\"Email Sent\"), 200)\n\n\n@auth_routes.route('/reset-password', methods=['PATCH'])\ndef reset_password_patch():\n    token = request.json['data']['token']\n    password = request.json['data']['password']\n\n    try:\n        user = User.query.filter_by(reset_password=token).one()\n    except NoResultFound:\n        return abort(\n            make_response(jsonify(error=\"User not found\"), 404)\n        )\n    else:\n        user.password = password\n        save_to_db(user)\n\n    return jsonify({\n        \"id\": user.id,\n        \"email\": user.email,\n        \"name\": user.name if user.get('name') else None\n    })\n\n\n@auth_routes.route('/change-password', methods=['POST'])\n@jwt_required()\ndef change_password():\n    old_password = request.json['data']['old-password']\n    new_password = request.json['data']['new-password']\n\n    try:\n        user = User.query.filter_by(id=current_user.id).one()\n    except NoResultFound:\n        return abort(\n            make_response(jsonify(error=\"User not found\"), 404)\n        )\n    else:\n        if user.is_correct_password(old_password):\n\n            user.password = new_password\n            save_to_db(user)\n        else:\n            return abort(\n                make_response(jsonify(error=\"Wrong Password\"), 400)\n            )\n\n    return jsonify({\n        \"id\": user.id,\n        \"email\": user.email,\n        \"name\": user.fullname if user.fullname else None,\n        \"password_changed\": True\n    })\n", "path": "app/api/auth.py"}]}