Skip to content

Commit

Permalink
Use Security.render_template in mails too (#53)
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 May 3, 2019
1 parent c3fdb73 commit e6d9ede
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 @@ -393,9 +392,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 e6d9ede

Please sign in to comment.