Skip to content

Commit

Permalink
Use Security.render_template in mails too (#35)
Browse files Browse the repository at this point in the history
Allows custom `render_template` function, mostly 
for theming support in mails.
  • Loading branch information
jwag956 committed Apr 28, 2019
1 parent 6e6f8d3 commit 0a1dcf3
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions flask_security/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@
from contextlib import contextmanager
from datetime import timedelta

from flask import current_app, flash, render_template, request, session, \
url_for
from flask import current_app, flash, request, session, url_for
from flask_login import login_user as _login_user
from flask_login import logout_user as _logout_user
from flask_mail import Message
Expand Down Expand Up @@ -389,9 +388,9 @@ def send_mail(subject, recipient, template, **context):

ctx = ('security/email', template)
if config_value('EMAIL_PLAINTEXT'):
msg.body = render_template('%s/%s.txt' % ctx, **context)
msg.body = _security.render_template('%s/%s.txt' % ctx, **context)
if config_value('EMAIL_HTML'):
msg.html = render_template('%s/%s.html' % ctx, **context)
msg.html = _security.render_template('%s/%s.html' % ctx, **context)

if _security._send_mail_task:
_security._send_mail_task(msg)
Expand Down

0 comments on commit 0a1dcf3

Please sign in to comment.