Skip to content
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

[ResetPassword & VerifyEmail] fix templated email "lifetime" being mutated by timezones #632

Closed
wants to merge 1 commit into from

Conversation

jrushlow
Copy link
Collaborator

Currently in the twig email templates, the This link will expire in 1 hour(s). is malformed if a timezone is set either in twig or in PHP.

In the controllers of both ResetPassword & VerifyEmail(RegistrationController) the token lifetime is expressed as int X. The lifetime is then passed to the twig templated email where it is ultimately passed to the date filter. This PR enforces that the lifetime value should always be formatted in the UTC timezone.

This is only a temporary solution. Ideally, either the ResetPasswordBundle & VerifyEmailBundle or MakerBundle should use a math based method to transform the lifetime value to a human readable format. e.g

$lifetime = 3600;   // seconds

public function convertToHours(int $lifetime): string

$result = ::convertToHours($lifetime);
// 1 hour

Refs SymfonyCasts/reset-password-bundle#119

@@ -3,7 +3,7 @@
<p>
Please confirm your email address by clicking the following link: <br><br>
<a href="{{ signedUrl|raw }}">Confirm my Email</a>.
This link will expire in {{ expiresAt|date('g') }} hour(s).
This link will expire in {{ expiresAt|date('g', 'UTC') }} hour(s).
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm probably missing something, but the g format outputs "12-hour format of an hour without leading zeros". So, if it's 8:35 AM it outputs 8 and if it's 17:21 PM it outputs 5.

that's why I think the text requires some rewording like this:

will expire in ... hour(s) --> will expire at ...

@jrushlow jrushlow added the Status: Needs Work Additional work is needed label Oct 27, 2020
@weaverryan weaverryan changed the base branch from master to main November 16, 2020 20:01
@jrushlow
Copy link
Collaborator Author

Closing this PR in favor of a better solution. Both ResetPassword and VerifyEmail will soon have built in translation support for the token / signature expiration time. Once this is available, we'll update the templates in a new PR here in maker.. This should also facilitate an easier path forward to adding those bundles to the demo app..

See:
SymfonyCasts/reset-password-bundle#135
SymfonyCasts/verify-email-bundle#43

@jrushlow jrushlow closed this Dec 14, 2020
@jrushlow jrushlow added the Bug Bug Fix label May 3, 2022
@jrushlow jrushlow deleted the feature/exp-auth branch May 3, 2022 19:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Bug Fix Status: Needs Work Additional work is needed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants