def reset_request(): if current_user.is_authenticated: return redirect(url_for('main.home')) form = RequestResetForm() if form.validate_on_submit(): user = User.query.filter_by(email=form.email.data).first() send_reset_email(user) flash( 'An email has been sent with instructions to reset your password.', 'info') return redirect(url_for('users.login')) return render_template('reset_request.html', title='Reset Password', form=form)
def reset_request(): if current_user.is_authenticated: return redirect(url_for('main.hello')) form = RequestResetForm() if form.validate_on_submit(): user = User.query.filter_by(email=form.email.data).first() send_reset_email(user) flash('На вашу почту отправлено письмо с инструкциями', 'info') return redirect(url_for('users.login')) context = { 'title': 'Восстановление пароля', } return render_template('reset_request.html', context=context, form=form)
def reset_password_request(body): """ Sends an email to reset password :param email: :return: """ email = body['email'] try: user = User.query.filter_by(email=email).first() send_reset_email(user) return 'An email has been sent with instructions to reset your password', 200 except Exception as e: response = jsonify({'message': str(e)}) return response, 401
def requestResetPassword(): print("REQUEST TO RESET PASSWORD") inputtedEmail = request.form.get('your_email') retrieveUser = User.query.filter_by(email=inputtedEmail).first_or_404() retrieveUserJSON = retrieveUser.as_dict() userCreds = send_reset_email(retrieveUserJSON) accessToken = create_access_token(userCreds) retMsg = { 'message': 'Reset Instructions Sent.', 'access_token': accessToken } return retMsg