bymayo / craft-porter

The missing toolbox for all things users (Delete Account, Password Policy, 2FA etc)
https://plugins.craftcms.com/porter
Other
1 stars 0 forks source link

Magic link timezones bugfix #5

Open RobinWissink opened 1 year ago

RobinWissink commented 1 year ago

Hi bymayo,

There is a bug, resulting in the Magic Link functionality not working for certain timezones. Craft saves DB entries in UTC. Therefore in certain timezones, a magic link will always be expired.

I believe the fix is as follows. On line 196 in MagicLink.php replace:

if (DateTimeHelper::currentTimeStamp() <= (strtotime($query->dateCreated) + $this->settings->magicLinkExpirySeconds))

With: if (DateTimeHelper::currentTimeStamp() <= (DateTimeHelper::toDateTime($query->dateCreated)->format('U') + $this->settings->magicLinkExpirySeconds))

Hope this helps. Would be great if you can update the plugin.

bymayo commented 1 year ago

@RobinWissink Sorry i've only just seen this! I'll get this sorted for the next release.