mvhub-dev team mailing list archive
-
mvhub-dev team
-
Mailing list archive
-
Message #00084
[Merge] lp:~priya/mvhub/move_sql_lib_authaccount into lp:mvhub
Priya Ravindran has proposed merging lp:~priya/mvhub/move_sql_lib_authaccount into lp:mvhub.
Requested reviews:
mvhub-dev (mvhub-dev)
MOved query from AUthAccount.pm to sql_select.lib and removed unused code for users.
--
https://code.launchpad.net/~priya/mvhub/move_sql_lib_authaccount/+merge/23493
Your team mvhub-dev is subscribed to branch lp:mvhub.
=== modified file 'app-mvhub/conf/sql_select.lib'
--- app-mvhub/conf/sql_select.lib 2010-04-06 15:14:41 +0000
+++ app-mvhub/conf/sql_select.lib 2010-04-15 18:10:36 +0000
@@ -77,6 +77,16 @@
FROM
agency
+[AGENCY_X_AUTH_AGENCY]
+SELECT
+ agency_id
+FROM
+ agency
+WHERE
+ agency_id=?
+AND
+ lower(password)=?
+
[AGENCY_X_EXPIRED_RECORDS]
SELECT
agency_id,
=== modified file 'app-mvhub/t/sql_lib_sanity.t'
--- app-mvhub/t/sql_lib_sanity.t 2010-04-06 15:14:41 +0000
+++ app-mvhub/t/sql_lib_sanity.t 2010-04-15 18:10:36 +0000
@@ -39,8 +39,9 @@
my %data = (
'AGENCY_X_AGENCY_NAME_PASSWORD' =>
[ 'chester@xxxxxxxxxxxxxx', 'chester@xxxxxxxxxxxxxx' ],
- 'AGENCY_X_EXPIRED_RECORDS' => [ '01-01-2008', 0 ],
- 'AGENCY_X_WEBSITE' => [103553],
+ 'AGENCY_X_AUTH_AGENCY' => [ '103553', '@lunch4all' ],
+ 'AGENCY_X_EXPIRED_RECORDS' => [ '01-01-2008', 0 ],
+ 'AGENCY_X_WEBSITE' => [103553],
'AGENCY_PROGRAM_X_AGENCY_NAME_AGENCY_ALIAS' => [510296],
'CATEGORY_PROGRAM_VIEW_HEADING_CATEGORY_X_ID_NAME_COUNT' =>
['Arts/Culture/Entertainment'],
=== modified file 'lib-mvhub/lib/MVHub/AuthAccount.pm'
--- lib-mvhub/lib/MVHub/AuthAccount.pm 2009-12-14 16:12:55 +0000
+++ lib-mvhub/lib/MVHub/AuthAccount.pm 2010-04-15 18:10:36 +0000
@@ -94,32 +94,16 @@
}
sub is_correct_password {
- my $dbh = shift;
- my $username = shift;
- my $password = shift;
- my $user_type;
-
- if ( $username =~ /^\d{6,7}$/ ) {
- $user_type = "agency";
- }
- else {
- $user_type = "user";
- }
-
- # Separated into two if-then blocks for clarity.
- # It might be faster to put SQL statements directly into
- # previous if-then block.
+ my $dbh = shift;
+ my $agency_id = shift;
+ my $password = shift;
+
my $stmt;
- if ( $user_type eq "agency" ) {
- $stmt
- = "SELECT agency_id FROM agency WHERE agency_id=? AND lower(password)=?";
- }
- else {
- $stmt
- = "SELECT username FROM users WHERE username=? AND lower(password)=?";
- }
+
+ $stmt = $dbh->retr_select_sql('AGENCY_X_AUTH_AGENCY');
+
my $rows_aref
- = $dbh->selectall_arrayref( $stmt, undef, $username, lc($password) );
+ = $dbh->selectall_arrayref( $stmt, undef, $agency_id, lc($password) );
return ( scalar @$rows_aref == 1 );
}
Follow ups