changeset da6317af93ea in modules/web_user:default details: https://hg.tryton.org/modules/web_user?cmd=changeset&node=da6317af93ea description: Add expire delay in reset password email
and use Genshi i18n issue11424 review382501002 diffstat: CHANGELOG | 2 ++ email_reset_password.html | 17 +++++++---------- email_validation.html | 13 ++++--------- user.py | 7 +++++++ 4 files changed, 20 insertions(+), 19 deletions(-) diffs (93 lines): diff -r e4e0a081a6fb -r da6317af93ea CHANGELOG --- a/CHANGELOG Mon May 02 16:48:21 2022 +0200 +++ b/CHANGELOG Mon May 09 23:43:12 2022 +0200 @@ -1,3 +1,5 @@ +* Add expire delay in reset password email + Version 6.4.0 - 2022-05-02 * Bug fixes (see mercurial logs for details) * Add support for Python 3.10 diff -r e4e0a081a6fb -r da6317af93ea email_reset_password.html --- a/email_reset_password.html Mon May 02 16:48:21 2022 +0200 +++ b/email_reset_password.html Mon May 09 23:43:12 2022 +0200 @@ -1,5 +1,5 @@ <!DOCTYPE html> -<html xmlns:py="http://genshi.edgewall.org/"> +<html xmlns:py="http://genshi.edgewall.org/" xmlns:i18n="http://genshi.edgewall.org/i18n"> <head> <title>Reset Password</title> </head> @@ -8,20 +8,17 @@ <div style="display: block; text-align: center"> <div> <h1>Reset Password</h1> - <p>We received a request to reset the password for your account, - ${user.email}</p> + <p i18n:msg="email">We received a request to reset the password for your account: ${user.email}</p> <a href="${user.get_email_reset_password_url()}" - style="display: block; text-decoration: none; - width: max-content; margin: 0 auto; - padding: 0.5em 1em; font-size:2em; - border: 1px solid #2E6DA4; border-radius: 4px; - color: #FFF; background-color: #337AB7;"> + style="display: block; text-decoration: none; width: max-content; margin: 0 auto; padding: 0.5em 1em; font-size:2em; border: 1px solid #2E6DA4; border-radius: 4px; color: #FFF; background-color: #337AB7;"> Reset Password </a> </div> - <hr style="margin-top: 20px; - border-style: solid none none; border-color: #EEE"></hr> + <hr style="margin-top: 20px; border-style: solid none none; border-color: #EEE"></hr> <div style="font-size: 80%; color: #777"> + <p i18n:msg="datetime,expire_delay"> + The link will expire in <time datetime="${record.reset_password_token_expire.isoformat()}">${format_timedelta(expire_delay)}</time>. + </p> <p>Button is not working? Paste this into your browser:</p> <p>${user.get_email_reset_password_url()}</p> <p>If you didn't make this request, you can ignore this email.</p> diff -r e4e0a081a6fb -r da6317af93ea email_validation.html --- a/email_validation.html Mon May 02 16:48:21 2022 +0200 +++ b/email_validation.html Mon May 09 23:43:12 2022 +0200 @@ -1,5 +1,5 @@ <!DOCTYPE html> -<html xmlns:py="http://genshi.edgewall.org/"> +<html xmlns:py="http://genshi.edgewall.org/" xmlns:i18n="http://genshi.edgewall.org/i18n"> <head> <title>Email Validation</title> </head> @@ -8,18 +8,13 @@ <div style="display: block; text-align: center"> <div> <h1>Just one more step..</h1> - <p>${user.email}</p> + <p i18n:msg="email">${user.email}</p> <a href="${user.get_email_validation_url()}" - style="display: block; text-decoration: none; - width: max-content; margin: 0 auto; - padding: 0.5em 1em; font-size:2em; - border: 1px solid #2E6DA4; border-radius: 4px; - color: #FFF; background-color: #337AB7;"> + style="display: block; text-decoration: none; width: max-content; margin: 0 auto; padding: 0.5em 1em; font-size:2em; border: 1px solid #2E6DA4; border-radius: 4px; color: #FFF; background-color: #337AB7;"> Validate </a> </div> - <hr style="margin-top: 20px; - border-style: solid none none; border-color: #EEE"></hr> + <hr style="margin-top: 20px; border-style: solid none none; border-color: #EEE"></hr> <div style="font-size: 80%; color: #777"> <p>Button is not working? Paste this into your browser:</p> <p>${user.get_email_validation_url()}</p> diff -r e4e0a081a6fb -r da6317af93ea user.py --- a/user.py Mon May 02 16:48:21 2022 +0200 +++ b/user.py Mon May 09 23:43:12 2022 +0200 @@ -518,4 +518,11 @@ def get_context(cls, records, header, data): context = super().get_context(records, header, data) context['extract_params'] = _extract_params + expire_delay = ( + records[0].reset_password_token_expire - datetime.datetime.now()) + # Use a precision of minutes + expire_delay = datetime.timedelta( + days=expire_delay.days, + minutes=round(expire_delay.seconds / 60)) + context['expire_delay'] = expire_delay return context