Merge pull request #2385 from BOINC/dpa_token

web: in download.php, use current login token if recent
This commit is contained in:
Kevin Reed 2018-03-07 11:11:42 -06:00 committed by GitHub
commit ce5d3ed79f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 2 deletions

View File

@ -20,11 +20,15 @@
// - forms for create / login
// - 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) {
$token = substr(random_string(), 0, 8);
$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");
return $token;
}