I noticed today while testing the expiration feature of the login links (using a purposefully backdated timestamp) that the links would always allow access no matter how old their timestamp was. After some debugging, I found that this was due to the module's call to variable_get on line 630:

$timeout = variable_get('login_one_time_expiry', 86400*14);

The $timeout variable was empty after this call, even though the call to variable_get should set 2 weeks as the default. Perhaps the variable existed in the database but was empty?

Checking the code for the configuration form seems to confirm this:

$form['global']['login_one_time_expiry'] = array(
    '#type' => 'textfield',
    '#title' => t('Link expiry'),
    '#default_value' => variable_get('login_one_time_expiry', ''),
    '#size' => strlen(PHP_INT_MAX),
    '#maxlength' => strlen(PHP_INT_MAX),
    '#description' => t("How long, in seconds, before links expire.  Leave blank to default to two weeks (1,209,600 seconds)."),
  );

Above at line 68 we have:

'#default_value' => variable_get('login_one_time_expiry', ''),

This would seem to set the variable to an empty string when the form was submitted, breaking the expiration check unless someone explicitly sets a timeout value on the config page.

In any case, once I entered a specific timeout value on the config page, the expiration check worked as expected. The instructions on the config page indicate that the field may be left blank for a default of 2 weeks, but this seems to not always be the case.

It seems that changing line 68 would fix this issue:

'#default_value' => variable_get('login_one_time_expiry', 86400*14),

Thanks for an excellent module - I'm using it to generate login links in bulk for around 12,000 users on one of our sites by calling the generation functions from a php script, then allowing the module's menu callbacks to handle authentication.

CommentFileSizeAuthor
#2 link_expiration_inop.patch1.47 KBacy76

Comments

acy76’s picture

Issue summary: View changes

additional explanation

acy76’s picture

Issue summary: View changes

more debugging info

acy76’s picture

Version: 6.x-2.3 » 6.x-2.8

I realized that my recommendation for added code above was not quite enough to fix the issue. Once the variable exists in the variables table, changing the default value won't have any effect - only saving the altered variable will work (the change above would probably fix the issue on a fresh installation, at least until someone entered and deleted an expiration time, resulting in an empty value again).

Adding a simple check for an empty $timeout value should fix the issue completely, after line 630 where the $timeout value is set in the user authentication function:

if (!$timeout) {
  $timeout = 86400*14;
}

I'll see about getting a patch together for these changes.

acy76’s picture

StatusFileSize
new1.47 KB

Attached is a patch for the changes discussed above.

danielb’s picture

Status: Active » Fixed

I did the second thing in the patch, not the first thing, should be enough.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

Anonymous’s picture

Issue summary: View changes

typo