summaryrefslogtreecommitdiffstats
path: root/Bugzilla/Token.pm
diff options
context:
space:
mode:
authorMax Kanat-Alexander <mkanat@bugzilla.org>2010-10-07 12:58:28 +0200
committerMax Kanat-Alexander <mkanat@bugzilla.org>2010-10-07 12:58:28 +0200
commit02a049703de6055f09f44f89a5a821814696ce32 (patch)
tree5918c91ceea49d280c8c3c0ce795da549a8bf4c6 /Bugzilla/Token.pm
parent7307c8c748e3245d65a25c016e7d92c6c7ae2aa4 (diff)
downloadbugzilla-02a049703de6055f09f44f89a5a821814696ce32.tar.gz
bugzilla-02a049703de6055f09f44f89a5a821814696ce32.tar.xz
Bug 602165: Change sql_interval to sql_date_math, in preparation for
MS-SQL and SQLite support.
Diffstat (limited to 'Bugzilla/Token.pm')
-rw-r--r--Bugzilla/Token.pm28
1 files changed, 14 insertions, 14 deletions
diff --git a/Bugzilla/Token.pm b/Bugzilla/Token.pm
index 06e95bb50..e15991f37 100644
--- a/Bugzilla/Token.pm
+++ b/Bugzilla/Token.pm
@@ -63,13 +63,14 @@ sub issue_new_user_account_token {
# But to prevent using this way to mailbomb an email address, make sure
# the last request is at least 10 minutes old before sending a new email.
- my $pending_requests =
- $dbh->selectrow_array('SELECT COUNT(*)
- FROM tokens
- WHERE tokentype = ?
- AND ' . $dbh->sql_istrcmp('eventdata', '?') . '
- AND issuedate > NOW() - ' . $dbh->sql_interval(10, 'MINUTE'),
- undef, ('account', $login_name));
+ my $pending_requests = $dbh->selectrow_array(
+ 'SELECT COUNT(*)
+ FROM tokens
+ WHERE tokentype = ?
+ AND ' . $dbh->sql_istrcmp('eventdata', '?') . '
+ AND issuedate > '
+ . $dbh->sql_date_math('NOW()', '-', 10, 'MINUTE'),
+ undef, ('account', $login_name));
ThrowUserError('too_soon_for_new_token', {'type' => 'account'}) if $pending_requests;
@@ -131,13 +132,12 @@ sub IssuePasswordToken {
my $user = shift;
my $dbh = Bugzilla->dbh;
- my $too_soon =
- $dbh->selectrow_array('SELECT 1 FROM tokens
- WHERE userid = ?
- AND tokentype = ?
- AND issuedate > NOW() - ' .
- $dbh->sql_interval(10, 'MINUTE'),
- undef, ($user->id, 'password'));
+ my $too_soon = $dbh->selectrow_array(
+ 'SELECT 1 FROM tokens
+ WHERE userid = ? AND tokentype = ?
+ AND issuedate > '
+ . $dbh->sql_date_math('NOW()', '-', 10, 'MINUTE'),
+ undef, ($user->id, 'password'));
ThrowUserError('too_soon_for_new_token', {'type' => 'password'}) if $too_soon;