Bug 1046126: Do not generate a new API token every time you access a bug-related page

r=sgreen,a=glob


git-svn-id: svn://10.0.0.236/trunk@265560 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
bzrmirror%bugzilla.org 2014-09-08 14:00:48 +00:00
parent 0ded788642
commit 82677cb98e
3 changed files with 12 additions and 5 deletions

View File

@ -1 +1 @@
9125
9126

View File

@ -1 +1 @@
fc4350ac3ae2a63ca423eef7c1406cd4c299d80e
e181022c27b291b845f029f0e8f25748cad8495f

View File

@ -34,9 +34,16 @@ use parent qw(Exporter);
# Create a token used for internal API authentication
sub issue_api_token {
# Generates a random token, adds it to the tokens table, and returns
# the token to the caller.
return _create_token(Bugzilla->user->id, 'api_token', '');
# Generates a random token, adds it to the tokens table if one does not
# already exist, and returns the token to the caller.
my $dbh = Bugzilla->dbh;
my $user = Bugzilla->user;
my ($token) = $dbh->selectrow_array("
SELECT token FROM tokens
WHERE userid = ? AND tokentype = 'api_token'
AND (" . $dbh->sql_date_math('issuedate', '+', (MAX_TOKEN_AGE * 24 - 12), 'HOUR') . ") > NOW()",
undef, $user->id);
return $token // _create_token($user->id, 'api_token', '');
}
# Creates and sends a token to create a new user account.