From 70eab04b845f550622af2b887f00718af13d755b Mon Sep 17 00:00:00 2001 From: Joseph Schorr Date: Thu, 29 Jan 2015 12:21:06 -0500 Subject: [PATCH] Add a tool for sending password reset emails --- tools/sendresetemail.py | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 tools/sendresetemail.py diff --git a/tools/sendresetemail.py b/tools/sendresetemail.py new file mode 100644 index 000000000..e977c654e --- /dev/null +++ b/tools/sendresetemail.py @@ -0,0 +1,27 @@ +from app import app + +from util.useremails import send_recovery_email + +from data import model + +import argparse + +from flask import Flask, current_app +from flask_mail import Mail + +def sendReset(username): + user = model.get_user(username) + if not user: + print 'No user found' + return + + + with app.app_context(): + code = model.create_reset_password_email_code(user.email) + send_recovery_email(user.email, code.code) + print 'Email sent to %s' % (user.email) + +parser = argparse.ArgumentParser(description='Sends a reset email') +parser.add_argument('username', help='The username') +args = parser.parse_args() +sendReset(args.username)