Ability to manage email subjects from configuration.

This commit is contained in:
Anthony Plunkett
2012-11-19 21:13:52 -05:00
parent 16976fce4e
commit 514d27fd66
6 changed files with 39 additions and 10 deletions
+21
View File
@@ -129,6 +129,27 @@ Feature Flags
to ``False``.
========================= ======================================================
Email
----------
.. tabularcolumns:: |p{6.5cm}|p{8.5cm}|
=========================================== ====================================
``SECURITY_EMAIL_SUBJECT_REGISTER`` Sets the subject for the
confirmation email. Defaults to
``Welcome``
``SECURITY_EMAIL_SUBJECT_PASSWORDLESS`` Sets the subject for the
passwordless feature. Defaults to
``Login instructions``
``SECURITY_EMAIL_SUBJECT_PASSWORD_NOTICE`` Sets subject for the password
notice. Defaults to
``Your password has been reset``
``SECURITY_EMAIL_SUBJECT_PASSWORD_RESET`` Sets the subject for the password
reset. Defaults to
``Password reset instructions``
``SECURITY_EMAIL_SUBJECT_CONFIRM`` Sets the subject for the email
confirmation message. Defaults to
``Please confirm your email``
Miscellaneous
-------------
+3 -2
View File
@@ -14,7 +14,8 @@ from datetime import datetime
from flask import current_app as app, request
from werkzeug.local import LocalProxy
from .utils import send_mail, md5, url_for_security, get_token_status
from .utils import send_mail, md5, url_for_security, get_token_status,\
config_value
from .signals import user_confirmed, confirm_instructions_sent
@@ -39,7 +40,7 @@ def send_confirmation_instructions(user):
confirmation_link, token = generate_confirmation_link(user)
send_mail('Please confirm your email', user.email,
send_mail(config_value('EMAIL_SUBJECT_CONFIRM'), user.email,
'confirmation_instructions', user=user,
confirmation_link=confirmation_link)
+6 -1
View File
@@ -61,7 +61,12 @@ _default_config = {
'RESET_SALT': 'reset-salt',
'LOGIN_SALT': 'login-salt',
'REMEMBER_SALT': 'remember-salt',
'DEFAULT_HTTP_AUTH_REALM': 'Login Required'
'DEFAULT_HTTP_AUTH_REALM': 'Login Required',
'EMAIL_SUBJECT_REGISTER': 'Welcome',
'EMAIL_SUBJECT_CONFIRM': 'Please confirm your email',
'EMAIL_SUBJECT_PASSWORDLESS': 'Login instructions',
'EMAIL_SUBJECT_PASSWORD_NOTICE': 'Your password has been reset',
'EMAIL_SUBJECT_PASSWORD_RESET': 'Password reset instructions'
}
#: Default Flask-Security messages
+3 -2
View File
@@ -13,7 +13,8 @@ from flask import request, current_app as app
from werkzeug.local import LocalProxy
from .signals import login_instructions_sent
from .utils import send_mail, url_for_security, get_token_status
from .utils import send_mail, url_for_security, get_token_status, \
config_value
# Convenient references
@@ -32,7 +33,7 @@ def send_login_instructions(user):
url = url_for_security('token_login', token=token)
login_link = request.url_root[:-1] + url
send_mail('Login Instructions', user.email,
send_mail(config_value('EMAIL_SUBJECT_PASSWORDLESS'), user.email,
'login_instructions', user=user, login_link=login_link)
login_instructions_sent.send(dict(user=user, login_token=token),
+3 -3
View File
@@ -14,7 +14,7 @@ from werkzeug.local import LocalProxy
from .signals import password_reset, reset_password_instructions_sent
from .utils import send_mail, md5, encrypt_password, url_for_security, \
get_token_status
get_token_status, config_value
# Convenient references
@@ -32,7 +32,7 @@ def send_reset_password_instructions(user):
url = url_for_security('reset_password', token=token)
reset_link = request.url_root[:-1] + url
send_mail('Password reset instructions', user.email,
send_mail(config_value('EMAIL_SUBJECT_PASSWORD_RESET'), user.email,
'reset_instructions',
user=user, reset_link=reset_link)
@@ -45,7 +45,7 @@ def send_password_reset_notice(user):
:param user: The user to send the notice to
"""
send_mail('Your password has been reset', user.email,
send_mail(config_value('EMAIL_SUBJECT_PASSWORD_NOTICE'), user.email,
'reset_notice', user=user)
+3 -2
View File
@@ -14,7 +14,8 @@ from werkzeug.local import LocalProxy
from .confirmable import generate_confirmation_link
from .signals import user_registered
from .utils import do_flash, get_message, send_mail, encrypt_password
from .utils import do_flash, get_message, send_mail, encrypt_password, \
config_value
# Convenient references
_security = LocalProxy(lambda: app.extensions['security'])
@@ -35,7 +36,7 @@ def register_user(**kwargs):
user_registered.send(dict(user=user, confirm_token=token),
app=app._get_current_object())
send_mail('Welcome', user.email, 'welcome',
send_mail(config_value('EMAIL_SUBJECT_REGISTER'), user.email, 'welcome',
user=user, confirmation_link=confirmation_link)
return user