From 2938b1cfa5400f6deaed8c89b3b03bab7499d8e5 Mon Sep 17 00:00:00 2001 From: prateekj117 Date: Tue, 9 Jul 2019 20:04:31 +0530 Subject: [PATCH 1/2] fix: Update password reset email to include token additionally --- app/api/auth.py | 22 +++++++++++----------- app/api/helpers/system_mails.py | 3 ++- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/app/api/auth.py b/app/api/auth.py index 4a6a577d90..127ea10231 100644 --- a/app/api/auth.py +++ b/app/api/auth.py @@ -1,37 +1,37 @@ -import os +import base64 import base64 import logging import random import string +from functools import wraps import requests -from healthcheck import EnvironmentDump -from functools import wraps -from flask import request, jsonify, make_response, Blueprint, send_file, url_for, redirect +from flask import request, jsonify, make_response, Blueprint, send_file from flask_jwt import current_identity as current_user, jwt_required from flask_limiter.util import get_remote_address +from healthcheck import EnvironmentDump from sqlalchemy.orm.exc import NoResultFound -from app.api.helpers.order import create_pdf_tickets_for_holder -from app.api.helpers.storage import generate_hash from app import get_settings from app import limiter +from app.api.helpers.auth import AuthManager from app.api.helpers.db import save_to_db, get_count from app.api.helpers.errors import ForbiddenError, UnprocessableEntityError, NotFoundError, BadRequestError from app.api.helpers.files import make_frontend_url from app.api.helpers.mail import send_email_with_action, \ send_email_confirmation from app.api.helpers.notification import send_notification_with_action +from app.api.helpers.order import create_pdf_tickets_for_holder +from app.api.helpers.storage import UPLOAD_PATHS +from app.api.helpers.storage import generate_hash from app.api.helpers.third_party_auth import GoogleOAuth, FbOAuth, TwitterOAuth, InstagramOAuth from app.api.helpers.utilities import get_serializer, str_generator from app.models import db -from app.models.order import Order from app.models.mail import PASSWORD_RESET, PASSWORD_CHANGE, \ - USER_REGISTER_WITH_PASSWORD, PASSWORD_RESET_AND_VERIFY + PASSWORD_RESET_AND_VERIFY from app.models.notification import PASSWORD_CHANGE as PASSWORD_CHANGE_NOTIF +from app.models.order import Order from app.models.user import User -from app.api.helpers.storage import UPLOAD_PATHS -from app.api.helpers.auth import AuthManager logger = logging.getLogger(__name__) authorised_blueprint = Blueprint('authorised_blueprint', __name__, url_prefix='/') @@ -232,7 +232,7 @@ def reset_password_post(): if user.was_registered_with_order: send_email_with_action(user, PASSWORD_RESET_AND_VERIFY, app_name=get_settings()['app_name'], link=link) else: - send_email_with_action(user, PASSWORD_RESET, app_name=get_settings()['app_name'], link=link) + send_email_with_action(user, PASSWORD_RESET, app_name=get_settings()['app_name'], link=link, token=user.reset_password) return make_response(jsonify(message="If your email was registered with us, you'll get an \ email with reset link shortly", email=email), 200) diff --git a/app/api/helpers/system_mails.py b/app/api/helpers/system_mails.py index 1e757295ad..6e0dc7941b 100644 --- a/app/api/helpers/system_mails.py +++ b/app/api/helpers/system_mails.py @@ -111,7 +111,8 @@ 'recipient': 'User', 'subject': u'{app_name}: Password Reset', 'message': ( - u"Please use the following link to reset your password.
{link}" + u"Please use the following link to reset your password.
{link}" + + " Or copy this token to your Eventyay App: {token} " ) }, PASSWORD_RESET_AND_VERIFY: { From 45b6060aa5f3510e83a6056c941ede357b1eff05 Mon Sep 17 00:00:00 2001 From: prateekj117 Date: Wed, 10 Jul 2019 15:02:55 +0530 Subject: [PATCH 2/2] Correct Grammar --- app/api/helpers/system_mails.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/api/helpers/system_mails.py b/app/api/helpers/system_mails.py index 6e0dc7941b..a1d4e160cf 100644 --- a/app/api/helpers/system_mails.py +++ b/app/api/helpers/system_mails.py @@ -112,7 +112,7 @@ 'subject': u'{app_name}: Password Reset', 'message': ( u"Please use the following link to reset your password.
{link}" + - " Or copy this token to your Eventyay App: {token} " + " Or paste this token in your {app_name} App: {token} " ) }, PASSWORD_RESET_AND_VERIFY: {