mirror of https://github.com/BOINC/boinc.git
web: in download.php, use current login token if recent
Generate a new login token only if the current one is older than a day. That way if a user does several downloads in quick succession (for whatever reason) autoattach will work with all of them.
This commit is contained in:
parent
4d3a787498
commit
3338fcdd19
|
@ -20,11 +20,15 @@
|
||||||
// - forms for create / login
|
// - forms for create / login
|
||||||
// - function to make login token
|
// - function to make login token
|
||||||
|
|
||||||
// make login token, store in user record, return token
|
// If have recent token, return it.
|
||||||
|
// Else make login token, store in user record, return token
|
||||||
//
|
//
|
||||||
function make_login_token($user) {
|
function make_login_token($user) {
|
||||||
$token = substr(random_string(), 0, 8);
|
|
||||||
$now = time();
|
$now = time();
|
||||||
|
if ($now - $user->login_token_time < 86400) {
|
||||||
|
return $user->login_token;
|
||||||
|
}
|
||||||
|
$token = substr(random_string(), 0, 8);
|
||||||
$user->update("login_token='$token', login_token_time=$now");
|
$user->update("login_token='$token', login_token_time=$now");
|
||||||
return $token;
|
return $token;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue