aboutsummaryrefslogtreecommitdiff
path: root/wqflask
diff options
context:
space:
mode:
Diffstat (limited to 'wqflask')
-rw-r--r--wqflask/wqflask/user_manager.py37
1 files changed, 26 insertions, 11 deletions
diff --git a/wqflask/wqflask/user_manager.py b/wqflask/wqflask/user_manager.py
index 755d64da..6e8f571e 100644
--- a/wqflask/wqflask/user_manager.py
+++ b/wqflask/wqflask/user_manager.py
@@ -55,7 +55,10 @@ logger = getLogger(__name__)
from base.data_set import create_datasets_list
import requests
-from utility.elasticsearch_tools import es, get_elasticsearch_connection, get_user_by_unique_column, save_user
+from utility.elasticsearch_tools import get_elasticsearch_connection, get_user_by_unique_column, save_user, es_save_data
+
+from smtplib import SMTP
+from utility.tools import SMTP_CONNECT, SMTP_USERNAME, SMTP_PASSWORD
THREE_DAYS = 60 * 60 * 24 * 3
#THREE_DAYS = 45
@@ -386,6 +389,7 @@ class ForgotPasswordEmail(VerificationEmail):
"email_address": toaddr,
"timestamp": timestamp()
}
+ es = get_elasticsearch_connection()
es_save_data(es, self.key_prefix, "local", data, verification_code)
subject = self.subject
@@ -437,7 +441,6 @@ def verify_email():
@app.route("/n/password_reset", methods=['GET'])
def password_reset():
logger.debug("in password_reset request.url is:", request.url)
-
# We do this mainly just to assert that it's in proper form for displaying next page
# Really not necessary but doesn't hurt
# user_encode = DecodeUser(ForgotPasswordEmail.key_prefix).reencode_standalone()
@@ -747,6 +750,7 @@ def forgot_password():
def forgot_password_submit():
params = request.form
email_address = params['email_address']
+ es = get_elasticsearch_connection()
user_details = get_user_by_unique_column(es, "email_address", email_address)
if user_details:
ForgotPasswordEmail(user_details["email_address"])
@@ -913,15 +917,26 @@ app.jinja_env.globals.update(url_for_hmac=url_for_hmac,
# Redis.rpush("mail_queue", msg)
def send_email(toaddr, msg, fromaddr="no-reply@genenetwork.org"):
- from smtplib import SMTP
- from utility.tools import SMTP_CONNECT, SMTP_USERNAME, SMTP_PASSWORD
- server = SMTP(SMTP_CONNECT)
- server.starttls()
- server.login(SMTP_USERNAME, SMTP_PASSWORD)
- server.sendmail(fromaddr, toaddr, msg)
- server.quit()
-
-
+ """Send an E-mail through SMTP_CONNECT host. If SMTP_USERNAME is not
+ 'UNKNOWN' TLS is used
+
+ """
+ if SMTP_USERNAME == 'UNKNOWN':
+ logger.debug("SMTP: connecting with host "+SMTP_CONNECT)
+ server = SMTP(SMTP_CONNECT)
+ server.sendmail(fromaddr, toaddr, msg)
+ else:
+ logger.debug("SMTP: connecting TLS with host "+SMTP_CONNECT)
+ server = SMTP(SMTP_CONNECT)
+ server.starttls()
+ logger.debug("SMTP: login with user "+SMTP_USERNAME)
+ server.login(SMTP_USERNAME, SMTP_PASSWORD)
+ logger.debug("SMTP: "+fromaddr)
+ logger.debug("SMTP: "+toaddr)
+ logger.debug("SMTP: "+msg)
+ server.sendmail(fromaddr, toaddr, msg)
+ server.quit()
+ logger.info("Successfully sent email to "+toaddr)
class GroupsManager(object):
def __init__(self, kw):