Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions flask_user/emails.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,8 @@ def send_password_changed_email(user):
subject, html_message, text_message = _render_email(
user_manager.password_changed_email_template,
user=user,
app_name=user_manager.app_name)
app_name=user_manager.app_name,
app_root_url=user_manager.app_root_url)

# Send email message using Flask-Mail
user_manager.send_email_function(email, subject, html_message, text_message)
Expand Down Expand Up @@ -159,7 +160,8 @@ def send_username_changed_email(user): # pragma: no cover
subject, html_message, text_message = _render_email(
user_manager.username_changed_email_template,
user=user,
app_name=user_manager.app_name)
app_name=user_manager.app_name,
app_root_url=user_manager.app_root_url)

# Send email message using Flask-Mail
user_manager.send_email_function(email, subject, html_message, text_message)
Expand Down
1 change: 1 addition & 0 deletions flask_user/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ def set_default_settings(user_manager, app_config):

# General settings
um.app_name = sd('USER_APP_NAME', 'AppName')
um.app_root_url = sd('USER_APP_ROOT_URL', False)

# Set default features
um.enable_change_password = sd('USER_ENABLE_CHANGE_PASSWORD', True)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
{% block message %}
<p>Your password has been changed.</p>
{% if user_manager.enable_forgot_password %}
<p>If you did not initiate this password change, <a href="{{ url_for('user.forgot_password', _external=True) }}">click here to reset it</a>.</p>
{% if app_root_url %}
<p>If you did not initiate this password change, <a href="{{app_root_url}}{{url_for('user.forgot_password')}}">click here to reset it</a>.</p>
{% else %}
<p>If you did not initiate this password change, <a href="{{ url_for('user.forgot_password', _external=True) }}">click here to reset it</a>.</p>
{% endif %}
{% endif %}
{% endblock %}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@ Your password has been changed.

{% if user_manager.enable_forgot_password -%}
If you did not initiate this password change, click the link below to reset it.
{{ url_for('user.forgot_password', _external=True) }}
{% if app_root_url %}
{{app_root_url}}{{url_for('user.forgot_password')}}
{% else %}
{{ url_for('user.forgot_password', _external=True) }}
{% endif %}
{% endif -%}
{% endblock %}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,11 @@

{% block message %}
<p>Your username has been changed.</p>
<p>If you did not initiate this username change, please <a href="{{ url_for('user.login', _external=True) }}">sign in</a> (using your email address) and change your password.</p>
<p>If you did not initiate this username change, please
{% if app_root_url %}
<a href="{{app_root_url}}{{url_for('user.login')}}">
{% else %}
<a href="{{ url_for('user.login', _external=True) }}">
{% endif %}
sign in</a> (using your email address) and change your password.</p>
{% endblock %}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@
Your username has been changed.

If you did not initiate this username change, please sign in (using your email address) and change your password.
{% if app_root_url %}
{{app_root_url}}{{url_for('user.login')}}
{% else %}
{{ url_for('user.login', _external=True) }}
{% endif %}
{% endblock %}


16 changes: 14 additions & 2 deletions flask_user/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,9 @@ def forgot_password():
# Generate reset password link
token = user_manager.generate_token(int(user.get_id()))
reset_password_link = url_for('user.reset_password', token=token, _external=True)
if user_manager.app_root_url:
reset_password_link = user_manager.app_root_url + url_for(
'user.reset_password', token=token)

# Send forgot password email
emails.send_forgot_password_email(user, user_email, reset_password_link)
Expand Down Expand Up @@ -501,6 +504,9 @@ def invite():
accept_invite_link = url_for('user.register',
token=token,
_external=True)
if user_manager.app_root_url:
accept_invite_link = user_manager.app_root_url + url_for(
'user.register', token=token)

# Store token
if hasattr(db_adapter.UserInvitationClass, 'token'):
Expand Down Expand Up @@ -654,6 +660,12 @@ def user_profile():
return render_template(user_manager.user_profile_template)


def _confirm_email_link(um, token):
if um.app_root_url:
return um.app_root_url + url_for('user.confirm_email', token=token)
return url_for('user.confirm_email', token=token, _external=True)


def _send_registered_email(user, user_email, require_email_confirmation=True):
user_manager = current_app.user_manager
db_adapter = user_manager.db_adapter
Expand All @@ -663,7 +675,7 @@ def _send_registered_email(user, user_email, require_email_confirmation=True):
# Generate confirm email link
object_id = user_email.id if user_email else int(user.get_id())
token = user_manager.generate_token(object_id)
confirm_email_link = url_for('user.confirm_email', token=token, _external=True)
confirm_email_link = _confirm_email_link(user_manager, token)

# Send email
emails.send_registered_email(user, user_email, confirm_email_link)
Expand All @@ -685,7 +697,7 @@ def _send_confirm_email(user, user_email):
# Generate confirm email link
object_id = user_email.id if user_email else int(user.get_id())
token = user_manager.generate_token(object_id)
confirm_email_link = url_for('user.confirm_email', token=token, _external=True)
confirm_email_link = _confirm_email_link(user_manager, token)

# Send email
emails.send_confirm_email_email(user, user_email, confirm_email_link)
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@

setup(
name='Flask-User',
version='0.6.1',
version='0.6.1+jcb.1',
url='http://github.com/lingthio/Flask-User',
license='BSD License',
author='Ling Thio',
Expand Down