-
Notifications
You must be signed in to change notification settings - Fork 156
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(recoverable): Add support for username recovery via simple login flows #1041
Changes from 4 commits
87ef66f
7ae5671
c92f69c
dbb8d7b
b2228b0
31a8ad2
600d7ee
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1155,6 +1155,38 @@ Recoverable | |
|
||
Default: ``_("Your password has been reset")``. | ||
|
||
.. py:data:: SECURITY_USERNAME_RECOVERY | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Given this is a separate feature - could you put this is its own 'section'
|
||
|
||
Specifies whether username recovery is enabled. | ||
|
||
Default: ``False``. | ||
|
||
.. versionadded:: 5.6.0 | ||
|
||
.. py:data:: SECURITY_USERNAME_RECOVERY_URL | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please add this to list of URLs below |
||
|
||
Specifies the username recovery URL. | ||
|
||
Default: ``"/recover-username"``. | ||
|
||
.. versionadded:: 5.6.0 | ||
|
||
.. py:data:: SECURITY_EMAIL_SUBJECT_USERNAME_RECOVERY | ||
|
||
Sets subject for the username recovery email. | ||
|
||
Default: ``_("Your requested username")``. | ||
|
||
.. versionadded:: 5.6.0 | ||
|
||
.. py:data:: SECURITY_USERNAME_RECOVERY_TEMPLATE | ||
|
||
Specifies the path to the template for the username recovery page. | ||
|
||
Default: ``"security/recover_username.html"``. | ||
|
||
.. versionadded:: 5.6.0 | ||
|
||
Change-Email | ||
------------ | ||
.. versionadded:: 5.5.0 | ||
|
@@ -1935,6 +1967,7 @@ A list of all templates: | |
* :py:data:`SECURITY_TWO_FACTOR_VERIFY_CODE_TEMPLATE` | ||
* :py:data:`SECURITY_TWO_FACTOR_SELECT_TEMPLATE` | ||
* :py:data:`SECURITY_TWO_FACTOR_SETUP_TEMPLATE` | ||
* :py:data:`SECURITY_USERNAME_RECOVERY_TEMPLATE` | ||
* :py:data:`SECURITY_US_SIGNIN_TEMPLATE` | ||
* :py:data:`SECURITY_US_SETUP_TEMPLATE` | ||
* :py:data:`SECURITY_US_VERIFY_TEMPLATE` | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -58,6 +58,7 @@ | |
TwoFactorSetupForm, | ||
TwoFactorVerifyCodeForm, | ||
VerifyForm, | ||
UsernameRecoveryForm, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: alphabetize |
||
unique_identity_attribute, | ||
) | ||
from .mail_util import MailUtil, EmailValidateException | ||
|
@@ -87,6 +88,7 @@ | |
user_confirmed, | ||
user_registered, | ||
user_not_registered, | ||
username_recovery_email_sent, | ||
us_security_token_sent, | ||
us_profile_changed, | ||
wan_deleted, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{# This template receives the following context: | ||
user - the entire user model object | ||
#} | ||
|
||
<p>{{ _fsdomain("Hello,") }}</p> | ||
<p>{{ _fsdomain("You recently requested to recover your username.") }}</p> | ||
<p>{{ _fsdomain("Your username is: %(username)s", username=user.username) }}</p> | ||
<p>{{ _fsdomain("If you did not initiate this request, you can safely ignore this email.") }}</p> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{# This template receives the following context: | ||
user - the entire user model object | ||
#} | ||
|
||
{{ _fsdomain("Hello,") }} | ||
{{ _fsdomain("You recently requested to recover your username.") }} | ||
{{ _fsdomain("Your username is: %(username)s", username=user.username) }} | ||
{{ _fsdomain("If you did not initiate this request, you can safely ignore this email.") }} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{% extends "security/base.html" %} | ||
{% from "security/_macros.html" import render_field_with_errors, render_field, render_field_errors, render_form_errors %} | ||
|
||
{% block content %} | ||
{% include "security/_messages.html" %} | ||
<h1>{{ _fsdomain('Username recovery') }}</h1> | ||
<form action="{{ url_for_security('recover_username') }}" method="post" name="username_recovery_form"> | ||
{{ render_form_errors(username_recovery_form) }} | ||
{{ render_field_with_errors(username_recovery_form.email) }} | ||
{{ render_field_errors(username_recovery_form.csrf_token) }} | ||
{{ render_field(username_recovery_form.submit) }} | ||
</form> | ||
{% include "security/_menu.html" %} | ||
{% endblock content %} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: alphabetize please!