It'd be convenient to change the hard-coded value for the one-time login to a variable that can be set in the database. Specifically, on sites that require admin approval, 24 hours might not be enough time for that link depending on the site's audience (such as business users away from their email for a weekend). 24 hours makes a lot of sense for forgotten passwords, but for approved users it could be a little short.

CommentFileSizeAuthor
#155 263932-155.patch4.96 KBsja112
#153 263932-153.patch5.98 KBsja112
#140 263932-140.patch5 KBzuhair_ak
#137 263932-137.patch5 KBzuhair_ak
#134 263932-134.patch5 KBhardikpandya
#134 interdiff_128-134.txt1.39 KBhardikpandya
#129 make_the_one_time_login-263932-128.patch5.01 KBinterx
#128 interdiff_128-124.txt2.45 KBizus
#128 make_the_one_time_login-263932-128.patch5.32 KBizus
#124 interdiff_123-124.txt1.75 KBizus
#124 make_the_one_time_login-263932-124.patch5.29 KBizus
#123 make_the_one_time_login-263932-123.patch5.37 KBizus
#116 interdiff-263932-114-116.txt1.74 KBmayurjadhav
#116 make_the_one_time_login-263932-116.patch5.75 KBmayurjadhav
#114 263932-113.patch5.69 KBcyberschorsch
#112 263932-110.patch5.69 KBPradnya Pingat
#112 interdiff-263932-99-110.txt2.98 KBPradnya Pingat
#109 make_the_one_time_login-263932-109.patch66.37 KBPradnya Pingat
#99 make_the_one_time_login-263932-99.patch5.13 KBcyberschorsch
#97 make_the_one_time_login-263932-97.patch4.86 KBcyberschorsch
#95 make_the_one_time_login-263932-95.patch4.86 KBcyberschorsch
#93 interdiff-263932-90-93.txt1.53 KBmarkdorison
#93 make_the_one_time_login-263932-93.patch11.14 KBmarkdorison
#90 make_the_one_time_login-263932-90.patch4.86 KBcyberschorsch
#87 make_the_one_time_login-263932-87.patch3.6 KBmayurjadhav
#81 interdiff.txt1.34 KBmarkdorison
#81 make_the_one_time_login-263932-81.patch3.88 KBmarkdorison
#80 make_the_one_time_login-263932-80.patch3.55 KBmariano.barcia
#74 make_the_one_time_login-263932-74.patch1.98 KBmarkdorison
#73 make_the_one_time_login-263932-63.patch1.66 KBmarkdorison
#64 make_the_one_time_login-263932-63.patch1.66 KBmariano.barcia
#62 make_the_one_time_login-263932-62.patch1.69 KBmariano.barcia
#57 make_the_one_time_login-263932-57.patch3.21 KBlammensj
#54 interdiff-263932-52-54.txt933 bytescyberschorsch
#54 263932-54.patch3.09 KBcyberschorsch
#52 make_the_one_time_login-263932-52.patch3.12 KBlammensj
#45 make_the_one_time_login-263932-45.patch2.58 KBsumitmadan
#41 oneTimeLoginTTL-263932.patch2.86 KBmikgreen
#39 oneTimeLoginTTL-263932-38.patch2.84 KBsumitmadan
#37 oneTimeLoginTTL-263932-37.patch2.79 KBkoolaidguy
#35 oneTimeLoginTTL-263932-35.patch2.78 KBkoolaidguy
#34 oneTimeLoginTTL-263932-34.patch2.78 KBkoolaidguy
#31 oneTimeLoginTTL-263932-31.patch3.23 KBkoolaidguy
#30 oneTimeLoginTTL-263932-30.patch1.68 KBkoolaidguy
#28 oneTimeLoginTTL-263932-28.patch1.69 KBkoolaidguy
#20 263932-20-user_settings_to_set_reset_timeout.patch943 bytesCauliflower
#19 263932-19-user_settings_to_set_reset_timeout.patch1.39 KBCauliflower
#16 263932-16-user_settings_to_set_reset_timeout.patch890 bytesCauliflower
#14 one_time_login_link_ttl_14.patch4.38 KBmkadin
#11 one_time_login_link_ttl_11.patch1.52 KBmkadin
#2 one_time_login_link_ttl-263932-2.patch1.49 KBmdupont

Comments

mdupont’s picture

Version: 7.x-dev » 8.x-dev

Bumping to 8.x.

mdupont’s picture

StatusFileSize
new1.49 KB

Quick patch attached allowing a configurable TTL for one-time login links. Configurable through admin/config/people/accounts. Restricted length to 10 digits, which already allows for a maximum TTL of more than 317 years... should be enough ^^

mdupont’s picture

Status: Active » Needs review
Issue tags: +Novice

Tagging Novice.

danielb’s picture

Just thinking out loud, but the size of integers is platform dependent, perhaps consider using PHP_INT_SIZE.

rickmanelius’s picture

Interesting. Will attempt as part of my 30 min of drupal community time tomorrow :)

rickmanelius’s picture

Also thinking out loud. Would it be a security risk to not have any time limit at all? (e.g. 0 for unlimited?)

rickmanelius’s picture

I can confirm that the patch works as directed.

I suggest we either add in the max php size and possibly an unlimited option now or open as another ticket. Thoughts?

mdupont’s picture

Some thoughts:
- limiting size to 8 numbers will already allow for a maximum timeout of more than 3 years and will always fit in an integer on 32 bits platforms
- which value is generally used throughout Drupal to mean "unlimited"? Is it 0 or is it a negative number (-1)? Currently there is no enforcement that only a positive value should be entered.

danielb’s picture

Typically 0 is used for 'unlimited' in Drupal in situations where a literal value of zero would be useless.
And 8 is probably a better limit. I don't know of any systems that support a max of fewer than 8 digits in an integer?

rickmanelius’s picture

I agree with #9. I knew in views, for example, 0 is often used to denote no limit.

A size of 8 seems fine. Anyone wanting longer is likely to just use 0 and be done with it.

mkadin’s picture

StatusFileSize
new1.52 KB

Here's a patch that is re-rolled for D8 and has shortened the length of the number of seconds to 8 digits.

I don't love that the time has to be entered in seconds...not a great way for newbies / non-technical folks to have to enter this. Could we use php's function that converts strings to time? Or maybe a select form element with 1-7 days instead?

kristen pol’s picture

Title: One-Time Login TTL » Make the one-time login time-to-live (TTL) value configurable
kristen pol’s picture

What about either:

1) Making pre-configured settings, e.g.

1 day
2 days
1 week
2 weeks
4 weeks

like what is done on the admin/config/development/performance page for Minimum cache lifetime and Expiration of cached pages.

or

2) Have the settings so they choose the number of days and hours, e.g.

2 days and 3 hours

and then it is converted to seconds.

mkadin’s picture

StatusFileSize
new4.38 KB

I like the drop down idea. Patch attached.

kristen pol’s picture

I applied the patch and confirmed that, after choosing a particular duration, the correct value was in the variable table in the database. In particular:

1 day = 86400
2 days = 172800
1 week = 604800
2 weeks = 1209600

Beyond that, I'm not sure what else can be easily tested.

Cauliflower’s picture

The patch in #14 works but contains some unnecessary spaces and rules. The patch could also be simplified because the timeout already uses a variable.

I made a new patch that fixes the remarks above.

kristen pol’s picture

The patch code looks good, but I haven't tested it and am pressed for time... hope someone else can try out soon.

Bußmeyer’s picture

applied the patch and works well for me.

Perhaps it might be a good idea to add more alternatives as items in the drop down?

Cauliflower’s picture

Thx both for reviewing!

I added a few more options:

  • 2 days
  • 3 days
  • 2 weeks
  • 4 weeks.

Is that long enough you think ?

Cauliflower’s picture

Sorry, patch in #19 contained some other changes as well. The patch attached to this comment is the right one.

Status: Needs review » Needs work
Issue tags: -Novice

The last submitted patch, 263932-20-user_settings_to_set_reset_timeout.patch, failed testing.

Cauliflower’s picture

Status: Needs work » Needs review
Issue tags: +Novice
derEremit’s picture

Version: 8.x-dev » 9.x-dev

post feature freeze for 8.x
forwarding to 9.x

catch’s picture

Version: 9.x-dev » 8.0.x-dev
Category: Feature request » Task
Issue summary: View changes

I'd put this into 8.0.x without a UI - having this hardcoded seems like an omission given the issue summary.

We could add a UI in 8.1.x.

Josh Benner’s picture

Status: Needs review » Closed (duplicate)

It seems this was essentially already done during some other refactoring. See user.settings.password_reset_timeout.

Josh Benner’s picture

Version: 8.0.x-dev » 8.1.x-dev
Status: Closed (duplicate) » Needs work

Actually, keeping open to add UI after 8.0.0

koolaidguy’s picture

Assigned: Unassigned » koolaidguy
Issue tags: +SprintWeekend2015

Adding this to D8

koolaidguy’s picture

Status: Needs work » Needs review
StatusFileSize
new1.69 KB

Adding the configurable timeout to D8

Status: Needs review » Needs work

The last submitted patch, 28: oneTimeLoginTTL-263932-28.patch, failed testing.

koolaidguy’s picture

StatusFileSize
new1.68 KB

Resubmitting patch after pull
Ignore this patch, a better patch is on the way.

koolaidguy’s picture

StatusFileSize
new3.23 KB

New patch that allows default setting for timeout to be preserved.

koolaidguy’s picture

Status: Needs work » Needs review

The last submitted patch, 30: oneTimeLoginTTL-263932-30.patch, failed testing.

koolaidguy’s picture

StatusFileSize
new2.78 KB

One more try to get this patch to work

koolaidguy’s picture

StatusFileSize
new2.78 KB

Re-rolled this patch, it seems to work fine on a brand new checkout.

Status: Needs review » Needs work

The last submitted patch, 35: oneTimeLoginTTL-263932-35.patch, failed testing.

koolaidguy’s picture

Status: Needs work » Needs review
StatusFileSize
new2.79 KB

I know this is getting crazy, there was a tab in the patch.

Status: Needs review » Needs work

The last submitted patch, 37: oneTimeLoginTTL-263932-37.patch, failed testing.

sumitmadan’s picture

Status: Needs work » Needs review
StatusFileSize
new2.84 KB

Rerolled the patch.

Status: Needs review » Needs work

The last submitted patch, 39: oneTimeLoginTTL-263932-38.patch, failed testing.

mikgreen’s picture

Status: Needs work » Needs review
StatusFileSize
new2.86 KB

Rerolling.

Status: Needs review » Needs work

The last submitted patch, 41: oneTimeLoginTTL-263932.patch, failed testing.

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, 41: oneTimeLoginTTL-263932.patch, failed testing.

sumitmadan’s picture

Status: Needs work » Needs review
StatusFileSize
new2.58 KB

Rerolled with the latest code.

Status: Needs review » Needs work

The last submitted patch, 45: make_the_one_time_login-263932-45.patch, failed testing.

sumitmadan’s picture

Version: 8.1.x-dev » 8.0.x-dev
Assigned: koolaidguy » Unassigned
Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, 45: make_the_one_time_login-263932-45.patch, failed testing.

deepakaryan1988’s picture

Issue tags: -SprintWeekend2015

Removing sprint weekend tag!!
As suggested by @YesCT

deepakaryan1988’s picture

Issue tags: +SprintWeekend2015

Sorry, these issues were actually worked on during the 2015 Global Sprint
Weekend https://groups.drupal.org/node/447258

lammensj’s picture

Status: Needs work » Needs review
StatusFileSize
new3.12 KB

Fixed the error: the config used in the controller and in the form (password_reset_timeout_override) was not configured in the schema.yml. Hence the failing tests.

cyberschorsch’s picture

Assigned: Unassigned » cyberschorsch

I am going to review this issue

cyberschorsch’s picture

Assigned: cyberschorsch » Unassigned
StatusFileSize
new3.09 KB
new933 bytes

Thank you for fixing this problem.

I reviewed it manually and I think this needed more work. It is possible to enter anything in this field and this is not how we should do it. Instead, I changed the type of the field to "number" and added a "min"-Value to the field.

McGo’s picture

I successfully reviewed the patch from #54 and it applies and works as expected. A better UI really is needed in 8.1.x presenting a drop down menu with predefined values.

McGo’s picture

Status: Needs review » Reviewed & tested by the community

Test passed, so i set it to RTBC

lammensj’s picture

Status: Reviewed & tested by the community » Needs review
StatusFileSize
new3.21 KB

I replaced the input field with a select list, with options as proposed in #15. I thought that this wasn't worth waiting for the 8.1 version, it was an easy edit.

cyberschorsch’s picture

Status: Needs review » Needs work

Hmm, I don't like this completely. I already talked with McGo about this and I think we should add another option "custom" in the select list which triggers a new field which lets you add an individual intervall in seconds.

lammensj’s picture

Aren't we overthinking this? I mean, it's the expiration time of the one-time-login link. I can't even remember if a client ever asked me if it could be changed...
For cache invalidation I can understand why someone would need the custom choice, but not for this...

andypost’s picture

Version: 8.0.x-dev » 8.2.x-dev
Category: Task » Feature request

this is a feature

mariano.barcia’s picture

The KISS principle is a good guide, let me ask the following questions:
a) what would be the use case for such additional "custom" field displaying on and off?
b) is that case popular enough to be in Drupal?
c) if yes, does it need to be in core?

Regarding the patch, I don't quite understand the need of the additional variable "password_reset_timeout_override". I'll try to achieve the same without it.

mariano.barcia’s picture

Status: Needs work » Needs review
StatusFileSize
new1.69 KB

New (simpler) patch, achieved same functionality without the additional variable.

Status: Needs review » Needs work

The last submitted patch, 62: make_the_one_time_login-263932-62.patch, failed testing.

mariano.barcia’s picture

Status: Needs work » Needs review
StatusFileSize
new1.66 KB

Patch re-rolled without CR line endings (doh!).

joshi.rohit100’s picture

Well what if I want my link to be expired on 3 days, 4 days, 3 weeks etc. ? So I guess I am not achieving this by select list.
So shouldn't this be a text field contains timestamp. This will give more flexibility.

thoughts ?

mariano.barcia’s picture

Well, the same argument would apply to the page cache max-age, and the options there are fixed and do not allow any 'custom' value. This is for simplicity, as specific values of ie. 3524 seconds would be no different than 3600 from a business user's perspective.

IMHO, this improved scale should be enough:
1 day
2 day
3 days
5 days
7 days
14 days
30 days

mariano.barcia’s picture

Issue tags: +DrupalCampES
fractile81’s picture

Howdy, all!

I originally created this issue and it was for an explicit use case: in our organization we had support staff that would send password reset emails for customers when they called in for assistance. Organization policy was to allow an individual 1 week to take action on a correspondence (e.g., they were away for vacation or a weekend and had no email). Given the possible lag-time in receiving an email, it made sense for the industry we focused on.

My two cents: I think a UI similar to the cache dropdown with pre-selected values is suitable. If it's a real concern, someone can manually set a value using a custom configuration (YAML, settings.php, etc.).

For the option names, I'd go with what's in #66 and change:
- 2 day => 2 days
- 7 days => 1 week
- 14 days => 2 weeks
- 30 days => 1 month (and have the value represent 28 days)

We should just KISS and mimic the cache dropdown: it maintains UX/DX consistency.

5hawn’s picture

Status: Needs review » Reviewed & tested by the community

Works for me. Applied the patch on both simplytest.me and my local environment.

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 64: make_the_one_time_login-263932-63.patch, failed testing.

mariano.barcia’s picture

(My last patch had passed, now it is failing? Seems like a new test in Migrate isn't doing very well?)

Ok, works for me too. There's one more thing that I find... disturbing in the force...

There is a mismatch between the options units, and the real value unit. The real value stored in the configuration is measured in seconds, while the options are in whatever days, weeks or months. So, what if someone provides a value of of 3456 seconds through a YAML configuration? When he loads this admin screen: which value will be shown set? Suppose is shows [the closest option to that value] set, but then, if you save, you will have changed the configuration without knowing.

The max-age code for page cache has to deal with this as well... would like to see how it's done.

fractile81’s picture

The page cache code doesn't do any special handling (at least in D7). If it's a large concern, the field type can be changed if the number of seconds don't match any that are supported, otherwise keep a select. I would think manually setting the value would be an edge case, though.

To help avoid this edge case even further, I wonder if we should include hours as options? This would allow for tighter security on the emailed login token. This is the opposite of my original use case, but I can see it being useful.

3600 - 1 hour
7200 - 2 hours
14400 - 4 hours
28800 - 8 hours
43200 - 12 hours

markdorison’s picture

Status: Needs work » Needs review
StatusFileSize
new1.66 KB
  • Added additional hour options detailed in #72.
  • Updated description text.
markdorison’s picture

StatusFileSize
new1.98 KB

Trying again with the correct patch file.

  • Added additional hour options detailed in #72.
  • Updated description text.

The last submitted patch, 73: make_the_one_time_login-263932-63.patch, failed testing.

mariano.barcia’s picture

I think we should check the timeout value before filling it in and, if it does NOT match any of the pre-set options, alert the user so she doesn't change it inadvertently. If someone decides to "inject" her own value here, we should allow for it, but also cover the case where the user actually wants to revert that to one of the pre-set options. So the pre-set options only need to be "good enough" for most users, which I think they already are.

We are limiting the TTL for added security (that's why we're not including "forever" in the options) and scaling down to "hours" seems too tight, just my opinion.

markdorison’s picture

I think we should check the timeout value before filling it in and, if it does NOT match any of the pre-set options, alert the user so she doesn't change it inadvertently. If someone decides to "inject" her own value here, we should allow for it, but also cover the case where the user actually wants to revert that to one of the pre-set options.

The case we are discussing here is not unique to this issue. I took a look at how core handles the max-age settings on the 'performance' configuration form. If a the stored setting matches one of the options, it selects it as the default. If the stored setting does not match any of the available options, it defaults to showing the first option in the list, which in this example is 'no caching'. I can see merit in improving the UX of how this is handled, but I might argue that it shouldn't be a blocker for this and could live in it's own issue.

scaling down to "hours" seems too tight

I would respectfully disagree with you there. I could easily imagine short settings being quite useful.

mariano.barcia’s picture

@marcdorison thank you for finding that code. I may add that the behavior you've described is not enforced, but a side-effect of the config value not being found in the preset options and defaulting to _some_ value, probably the first element. And the first element (no caching) is not really the safest option is it?

In that code, and in this patch we're working on, I believe the user should be alerted somehow, and I agree it could be handled in separate issues, so as to unblock this one.

I could easily imagine short settings being quite useful.

It makes little to no technical difference, but I'm just curious, could you describe one use case? Thank you in advance.

fractile81’s picture

Drupal sites have a vast range of security and accessibility needs. We're only trying to remove a hard-coded 1-day TTL and provide a form field with a range of options that should suit most sites. Options under and over a day, at the aforementioned intervals, should fulfill this goal.

The hourly use cases benefit sites that want tighter security with little moderation. I can imagine a commerce site wanting to reduce the amount of time a "log in for free!" token stays alive. If a user is actively trying to reset their password, and assuming the internet is working at an adequate speed, the span of a whole day to reset their password seems excessive when some form of MITM attack could be executed on the email and compromise an account that has purchasing power. Another case could be for a public-facing "intranet" site: internal emails should route quickly, so having the TTL set so long shouldn't be needed. Simply adding these hourly options is an easy way to give site builders a choice in how to further manage their security.

mariano.barcia’s picture

StatusFileSize
new3.55 KB

Alright, so in this new patch attached, I've:

  • preserved the scale ranging from 1 hour to 2 weeks
  • changed how the options are built, to match the code in max-age page cache form. It is a bit more code but it is more consistent to use a date formatter with array_map().
  • reset to a default of "1 day" if a current value exists and differs (or there's no existing value for this setting).
  • not added any kind of feedback if the existing value does not match any option and hence, gets reverted to the default of 1 day.

Hope you find it useful, please test, thank you all.

markdorison’s picture

StatusFileSize
new3.88 KB
new1.34 KB

Patch tested fine.

  • Resolved PHPCS warning RE: $timeout_scale array declaration: "If the line declaring an array spans longer than 80 characters, each element should be broken into its own line."
  • Appended period to the end of the #description text.
adamzimmermann’s picture

+++ b/core/modules/user/src/AccountSettingsForm.php
@@ -181,6 +191,35 @@ public function buildForm(array $form, FormStateInterface $form_state) {
+      '#description' => t('Select how long the one-time login link will be valid. Default is 1 day.'),

Grammatically this should use "one day" instead of "1 day". However, "1 day" matches the output of dateFormatter, so perhaps we leave it as is?

Other than that, the code looks good and seems to be working in my basic testing.

mariano.barcia’s picture

Status: Needs review » Reviewed & tested by the community

Yeah "1 day" is good as it matches the value option. Also, note that "one day" may also mean "one day..." like in ie. www . peaceoneday . org

As 3 of us have tested the last patch with success, I'm marking this one as reviewed.

alexpott’s picture

Title: Make the one-time login time-to-live (TTL) value configurable » Make the one-time login time-to-live (TTL) value configurable in the UI

It's already configurable - just not through the UI.

alexpott’s picture

Status: Reviewed & tested by the community » Needs work
Issue tags: +Needs tests

We should at least test that the configuration is successfully saved by the form.

alexpott’s picture

+++ b/core/modules/user/src/AccountSettingsForm.php
@@ -181,6 +191,35 @@ public function buildForm(array $form, FormStateInterface $form_state) {
+    $login_link_default_ttl = $config->get('password_reset_timeout');
+    if (empty($login_link_default_ttl) || !in_array(intval($login_link_default_ttl), $timeout_scale)) {
+      $login_link_default_ttl = 86400;
+    }
...
+      '#default_value' => $login_link_default_ttl,

This looks unnecessary. The default value could only be empty if the user has hacked config. I would just do:
'#default_value' => $config->get('password_reset_timeout'),

mayurjadhav’s picture

Status: Needs work » Needs review
StatusFileSize
new3.6 KB

Hi,
@alexpott make sense, we can directly add

'#default_value' => $config->get('password_reset_timeout'),

I manually tested it and the configuration is successfully saved by the form.
Uploading patch with making #86 changes.

Thanks.

alexpott’s picture

still need an automated test. Maybe add a new test method to UserAdminTest

markdorison’s picture

Status: Needs review » Needs work
cyberschorsch’s picture

Status: Needs work » Needs review
Issue tags: +DevDaysMilan
StatusFileSize
new4.86 KB

I added a test which sets the TTL to 1 hour and saves the form. Afterwards, it checks the config for the stored TTL.

Status: Needs review » Needs work

The last submitted patch, 90: make_the_one_time_login-263932-90.patch, failed testing.

zserno’s picture

Great effort, @Cyberschorsch. I found the following minor issues:

  1. +++ b/core/modules/user/src/AccountSettingsForm.php
    @@ -181,6 +191,29 @@ public function buildForm(array $form, FormStateInterface $form_state) {
    +      '#description' => t('Select how long the one-time login link will be valid. Default is 1 day.'),
    

    As per #82 this should say "one day".

  2. +++ b/core/modules/user/src/Tests/UserAdminTest.php
    @@ -197,4 +197,21 @@ function testNotificationEmailAddress() {
    +    // Check the stored value after form submit, should be 1 hour.s
    

    Typo at the end of the sentence: "...1hour.s"

markdorison’s picture

Status: Needs work » Needs review
StatusFileSize
new11.14 KB
new1.53 KB

Fixed issues detailed in #82 & #92.

cyberschorsch’s picture

Status: Needs review » Needs work

A, I see you uploaded the wrong patch. Let me change that real quick

cyberschorsch’s picture

Status: Needs work » Needs review
StatusFileSize
new4.86 KB

Fixed the typos.

markdorison’s picture

Status: Needs review » Needs work
+++ b/core/modules/user/src/Tests/UserAdminTest.php
@@ -197,4 +197,21 @@ function testNotificationEmailAddress() {
+    // Check the stored value after form submit, should be 1 hours.

I believe a semi-colon here makes more sense than a comma, but I am fine with it either way.

+++ b/core/modules/user/src/Tests/UserAdminTest.php
@@ -197,4 +197,21 @@ function testNotificationEmailAddress() {
+    // Check the stored value after form submit, should be 1 hours.

However, '1 hours' should be the singular '1 hour'.

cyberschorsch’s picture

Status: Needs work » Needs review
StatusFileSize
new4.86 KB

Okay, changed it.

duaelfr’s picture

Issue tags: -Needs tests

Good work here!
Reviewing the code I only have two tidbits:

  1. +++ b/core/modules/user/src/AccountSettingsForm.php
    @@ -38,8 +46,9 @@ class AccountSettingsForm extends ConfigFormBase {
    -  public function __construct(ConfigFactoryInterface $config_factory, ModuleHandlerInterface $module_handler, RoleStorageInterface $role_storage) {
    +  public function __construct(ConfigFactoryInterface $config_factory, DateFormatterInterface $date_formatter, ModuleHandlerInterface $module_handler, RoleStorageInterface $role_storage) {
    

    [Documentation] The docblock of this method must be updated by mentioning the new parameter.

  2. +++ b/core/modules/user/src/AccountSettingsForm.php
    @@ -181,6 +191,29 @@ public function buildForm(array $form, FormStateInterface $form_state) {
    +      3600,
    +      7200,
    +      14400,
    +      28800,
    +      43200,
    +      86400,
    +      172800,
    +      604800,
    +      1209600,
    

    [DX] Could we have some comments on each line to show the human readable value?
    ie. 3600, // 1 hour
    604800, // 7 days

cyberschorsch’s picture

StatusFileSize
new5.13 KB

Good catch, DualFR!

I updated the documentation, also rebased again.

dawehner’s picture

As said it would be nice to remove the description as there is really no value in it. It says the exactly same as the title.

markdorison’s picture

Status: Needs review » Needs work

The changes in this patch do not conform to Drupal coding standards:

  1. +++ b/core/modules/user/src/AccountSettingsForm.php
    @@ -181,6 +193,29 @@ public function buildForm(array $form, FormStateInterface $form_state) {
    +    $timeout_scale = array(
    +      3600, // 1 hour,
    +      7200, // 2 hours
    +      14400, // 4 hours
    +      28800, // 8 hours
    +      43200, // 12 hours
    +      86400, // 1 day
    +      172800, // 2 days
    +      604800, // 1 week
    +      1209600, // 2 weeks
    +    );
    

    The comments added per #98 do not pass PHPCS.

    198 | ERROR | [x] Comments may not appear after statements
    199 | ERROR | [x] Comments may not appear after statements
    200 | ERROR | [x] Comments may not appear after statements
    201 | ERROR | [x] Comments may not appear after statements
    202 | ERROR | [x] Comments may not appear after statements
    203 | ERROR | [x] Comments may not appear after statements
    204 | ERROR | [x] Comments may not appear after statements
    205 | ERROR | [x] Comments may not appear after statements

  2. +++ b/core/modules/user/src/Tests/UserAdminTest.php
    @@ -197,4 +197,21 @@ function testNotificationEmailAddress() {
    +   * Test saving the time-to-live (ttl) for the one-time login link when
    
    202 | ERROR | [ ] Doc comment short description must be on a single line, further text should be a separate paragraph
  3. +++ b/core/modules/user/src/Tests/UserAdminTest.php
    @@ -197,4 +197,21 @@ function testNotificationEmailAddress() {
    +  function testOnetimeLoginLinkTTL() {
    
    204 | ERROR | [ ] Method name "UserAdminTest::testOnetimeLoginLinkTTL" is not in lowerCamel format
    204 | ERROR | [ ] Visibility must be declared on method "testOnetimeLoginLinkTTL"
  4. +++ b/core/modules/user/src/Tests/UserAdminTest.php
    @@ -197,4 +197,21 @@ function testNotificationEmailAddress() {
    +  }
    
    216 | ERROR | [x] Expected 1 blank line after function; 0 found
    217 | ERROR | [x] The closing brace for the class must have an empty line before it
Pradnya Pingat’s picture

Assigned: Unassigned » Pradnya Pingat
Pradnya Pingat’s picture

I am trying to apply patch but its not getting apply .So changing status from needs work to needs reroll.

Pradnya Pingat’s picture

Status: Needs work » Patch (to be ported)
Pradnya Pingat’s picture

Assigned: Pradnya Pingat » Unassigned
Status: Patch (to be ported) » Fixed

by mistakenly marked as resolved

Pradnya Pingat’s picture

Status: Fixed » Needs work
Issue tags: +Needs reroll
markdorison’s picture

Issue tags: -Needs reroll

@Pradnya The latest patch applies cleanly against HEAD of 8.2.x. Are you trying to apply against that branch?

Pradnya Pingat’s picture

@markdorison Yes ,let me try Once again and get back to you.

Pradnya Pingat’s picture

StatusFileSize
new66.37 KB

@markdorison Sorry my bad .patch applies cleanly. Making changes as per coding standards.

cyberschorsch’s picture

Why is your patch this large? It seems like you changed the intendation?

I think we should focus on the actual issue here. When we fix the comments, I think this issue is done..

ashishdalvi’s picture

@Pradnya Pingat : Patch submitted by you seems to be incorrect patch. Please verify your submitted patch.

Pradnya Pingat’s picture

Status: Needs work » Needs review
StatusFileSize
new2.98 KB
new5.69 KB

mistakenly uploaded file .Adding new patch file with coding standard fixes as per comment #101

cyberschorsch’s picture

The "hours" wording error was still present, corrected that.

cyberschorsch’s picture

StatusFileSize
new5.69 KB
duaelfr’s picture

Status: Needs review » Needs work

Thank you all for your work here! You're on the right way!
Here are a few more things, though.

+++ b/core/modules/user/src/AccountSettingsForm.php
@@ -181,6 +190,29 @@ public function buildForm(array $form, FormStateInterface $form_state) {
+    $timeout_scale = array(
+      3600, // 1 hour.
+      7200, // 2 hours.
+      14400, // 4 hours.
+      28800, // 8 hours.
+      43200, // 12 hours.
+      86400, // 1 day.
+      172800, // 2 days.
+      604800, // 1 week.
+      1209600, // 2 weeks.
+    );

To pass PHPCS validation the comments have to be on the line before the statement. eg:

// 1 hour.
3600,
// 4 hours.
14400,

Some other points from #101 haven't been fixed yet.

mayurjadhav’s picture

Status: Needs work » Needs review
StatusFileSize
new5.75 KB
new1.74 KB

Updated the patch with suggested changes in #101 and #115.

Version: 8.2.x-dev » 8.3.x-dev

Drupal 8.2.0-beta1 was released on August 3, 2016, which means new developments and disruptive changes should now be targeted against the 8.3.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

quietone’s picture

Status: Needs review » Needs work

What an interesting find. It would be handy to have this functionality.

I read through the issue and the only thing I found not addressed was dawehner's comment in #100 about removing the description.

+++ b/core/modules/user/src/AccountSettingsForm.php
@@ -49,9 +60,7 @@ public function __construct(ConfigFactoryInterface $config_factory, ModuleHandle
+      $container->get('config.factory'), $container->get('date.formatter'), $container->get('module_handler'), $container->get('entity.manager')->getStorage('user_role')

Line > 80 characters. And is there a reason the data formatter wasn't added at the end of the list of returned items?

+++ b/core/modules/user/src/Tests/UserAdminTest.php
@@ -197,4 +197,21 @@ function testNotificationEmailAddress() {
+    $this->assertEqual($ttl, 3600, 'Testing the stored ttl of password reset in the configuration');

Capitalize the acronym, TTL.

+++ b/core/modules/user/src/Tests/UserAdminTest.php
@@ -197,4 +197,21 @@ function testNotificationEmailAddress() {
+   * Test saving TTL for the one-time login link on resetting a user password.

Shouldn't TTL be stated in full before the abbreviation? As in 'Test saving the time to live (TTL) for ...'

Version: 8.3.x-dev » 8.4.x-dev

Drupal 8.3.0-alpha1 will be released the week of January 30, 2017, which means new developments and disruptive changes should now be targeted against the 8.4.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.0-alpha1 will be released the week of July 31, 2017, which means new developments and disruptive changes should now be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.0-alpha1 will be released the week of January 17, 2018, which means new developments and disruptive changes should now be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.6.x-dev » 8.7.x-dev

Drupal 8.6.0-alpha1 will be released the week of July 16, 2018, which means new developments and disruptive changes should now be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

izus’s picture

StatusFileSize
new5.37 KB

pure reroll of #116

izus’s picture

Status: Needs work » Needs review
StatusFileSize
new5.29 KB
new1.75 KB

hi,
here is a patch that adresses #118
Thanks

interx’s picture

Thanks, this patch comes in handy. It makes the contrib solution User Password Reset Link Timeout no longer necessary to simply adjust a core variable.

I tested the patch and it works for me.

Some remarks on the patch:

+++ b/core/modules/user/src/AccountSettingsForm.php
@@ -51,9 +62,7 @@ public function __construct(ConfigFactoryInterface $config_factory, ModuleHandle
+      $container->get('config.factory'), $container->get('date.formatter'), $container->get('module_handler'), $container->get('entity.manager')->getStorage('user_role')

Why move the services onto one line instead of keeping them on multiple lines?

+++ b/core/modules/user/tests/src/Functional/UserAdminTest.php
@@ -202,4 +202,21 @@ public function testNotificationEmailAddress() {
+    $admin_user = $this->drupalCreateUser(array('administer account settings'));

This needs to use the short array syntax.

+++ b/core/modules/user/tests/src/Functional/UserAdminTest.php
@@ -202,4 +202,21 @@ public function testNotificationEmailAddress() {
+    $this->drupalPostForm("/admin/config/people/accounts", $edit, t('Save configuration'))

Single quotes should be used by default.

interx’s picture

Status: Needs review » Needs work
andypost’s picture

+++ b/core/modules/user/src/AccountSettingsForm.php
@@ -183,6 +192,37 @@ public function buildForm(array $form, FormStateInterface $form_state) {
+      '#title' => t('How long will a one-time login link be valid?'),

Use $this->t()

izus’s picture

Status: Needs work » Needs review
StatusFileSize
new5.32 KB
new2.45 KB

Hi,
Thanks for reviews
here is a patch that adresses #125 and #127
Thanks

interx’s picture

StatusFileSize
new5.01 KB

Here's a patch that fixes the minor coding standards

interx’s picture

@izus you beat me to it, almost submitted a patch simultaniously :)

I moved the DateFormatter service to the end of the list for classes that already extend AccountSettingsForm. Seems to make more sense to not inject new services in the middle of others.

jollysolutions’s picture

Issue tags: +DistributedSprintUK18
jollysolutions’s picture

Status: Needs review » Reviewed & tested by the community

#129 Tested and works for me

larowlan’s picture

Status: Reviewed & tested by the community » Needs work
+++ b/core/modules/user/src/AccountSettingsForm.php
@@ -183,6 +195,37 @@ public function buildForm(array $form, FormStateInterface $form_state) {
+    $timeout_scale = array(
...
+    $form['registration_cancellation']['user_pass_reset_timeout'] = array(

this needs to use short array syntax

Thanks for working on this

hardikpandya’s picture

Status: Needs work » Needs review
StatusFileSize
new1.39 KB
new5 KB
izus’s picture

Status: Needs review » Reviewed & tested by the community

Hi,

#134 Tested and works for me

the two modifications adviced in #133 were adressed by #134
so back to RTBTC

Thanks

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 134: 263932-134.patch, failed testing. View results

zuhair_ak’s picture

Status: Needs work » Needs review
StatusFileSize
new5 KB

Rerun the test bots again

jollysolutions’s picture

Status: Needs review » Reviewed & tested by the community

#137 works for me

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 137: 263932-137.patch, failed testing. View results

zuhair_ak’s picture

Status: Needs work » Needs review
StatusFileSize
new5 KB

Running the testbots again

andypost’s picture

Status: Needs review » Reviewed & tested by the community

Back to rtbc

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 140: 263932-140.patch, failed testing. View results

zuhair_ak’s picture

Status: Needs work » Reviewed & tested by the community

Retests are passed. We will set it again to RTBC and see what bot says.

catch’s picture

Issue tags: +Needs usability review

Tagging for usability review.

gábor hojtsy’s picture

What's the use case for week and two weeks? The issue summary explains business users and weekends as use case for 2 days, but weeks came up later. They could still ask for another login link. I recently got beaten multiple times by Google's login tokens expiring in a few hours, but these limits are in the interest of security.

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 140: 263932-140.patch, failed testing. View results

Anonymous’s picture

Status: Needs work » Needs review

Version: 8.7.x-dev » 8.8.x-dev

Drupal 8.7.0-alpha1 will be released the week of March 11, 2019, which means new developments and disruptive changes should now be targeted against the 8.8.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

kenton.r’s picture

I am using the 263932-140.patch and I use it at 2 weeks. My use case is that I import user accounts and send the links which have an average of click time of one week for the individuals to follow through with the registration process. They are not the ones who initiate the email so there needs to be time for them to find time in their schedule to finish the registration.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.0-alpha1 will be released the week of October 14th, 2019, which means new developments and disruptive changes should now be targeted against the 8.9.x-dev branch. (Any changes to 8.9.x will also be committed to 9.0.x in preparation for Drupal 9’s release, but some changes like significant feature additions will be deferred to 9.1.x.). For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.9.x-dev » 9.1.x-dev

Drupal 8.9.0-beta1 was released on March 20, 2020. 8.9.x is the final, long-term support (LTS) minor release of Drupal 8, which means new developments and disruptive changes should now be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

quietone’s picture

Status: Needs review » Needs work
Issue tags: -Novice +Needs issue summary update

I skimmed through the issue and it isn't clear what the next step is, but it certainly isn't novice anymore. Also needs IS update. And note that this has security factor to consider, as mention in #145.

And the patch needs a reroll.

sja112’s picture

Status: Needs work » Needs review
StatusFileSize
new5.98 KB

Patch re-rolled.

Status: Needs review » Needs work

The last submitted patch, 153: 263932-153.patch, failed testing. View results

sja112’s picture

Status: Needs work » Needs review
StatusFileSize
new4.96 KB

Uploaded incorrect patch in #153.

Status: Needs review » Needs work

The last submitted patch, 155: 263932-155.patch, failed testing. View results

Version: 9.1.x-dev » 9.2.x-dev

Drupal 9.1.0-alpha1 will be released the week of October 19, 2020, which means new developments and disruptive changes should now be targeted for the 9.2.x-dev branch. For more information see the Drupal 9 minor version schedule and the Allowed changes during the Drupal 9 release cycle.

Version: 9.2.x-dev » 9.3.x-dev

Drupal 9.2.0-alpha1 will be released the week of May 3, 2021, which means new developments and disruptive changes should now be targeted for the 9.3.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.0-rc1 was released on November 26, 2021, which means new developments and disruptive changes should now be targeted for the 9.4.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.0-alpha1 was released on May 6, 2022, which means new developments and disruptive changes should now be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.5.x-dev » 10.1.x-dev

Drupal 9.5.0-beta2 and Drupal 10.0.0-beta2 were released on September 29, 2022, which means new developments and disruptive changes should now be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 10.1.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch, which currently accepts only minor-version allowed changes. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 11.x-dev » main

Drupal core is now using the main branch as the primary development branch. New developments and disruptive changes should now be targeted to the main branch.

Read more in the announcement.