← Back to team overview

mvhub-dev team mailing list archive

[Merge] lp:~leegoodrich/mvhub/refactor_quick_login_id into lp:mvhub

 

Lee Goodrich has proposed merging lp:~leegoodrich/mvhub/refactor_quick_login_id into lp:mvhub.

Requested reviews:
  MVHub devs with commit rights (mvhub-commit)


This changes the way that the quick login urls are generated and stored. The old way was to use a simple mathematical formula to encode the agency_id and then decode it on retrieval. This was unsecure, so now the quick login id is generated via a random number sequence converted to hex and stored in a dedicated column in the agency table in the database. Everything that used quick logins (just the notification email and display agency admin page) has been refactored to use the new system, and all the tests that touch quick logins have been modified as well.
-- 
https://code.launchpad.net/~leegoodrich/mvhub/refactor_quick_login_id/+merge/29914
Your team MVHub Developers is subscribed to branch lp:mvhub.
=== removed file 'app-mvhub/bin/welcome_email.pl'
--- app-mvhub/bin/welcome_email.pl	2010-06-17 18:46:44 +0000
+++ app-mvhub/bin/welcome_email.pl	1970-01-01 00:00:00 +0000
@@ -1,214 +0,0 @@
-#!/usr/bin/perl
-
-# $Revision: 1467 $
-
-use strict;
-use warnings;
-use DBI;
-use HTML::Template;
-
-use lib '../../cgi-bin/guide';
-use MVHub::Common;
-
-my $AGENCY_EMAIL_TEMPLATE  = './welcome_agency_email.tmpl';
-my $PROGRAM_EMAIL_TEMPLATE = './welcome_program_email.tmpl';
-
-# Definitions:
-#
-# We assert that a contact is uniquely identified by its first name, last name,
-# email address and agency_id.
-#
-# ac = agency contact (who may also be the contact for one or more program(s)
-# pc = program contact (who is NOT also the agency contact)
-
-#TESTING: at least:
-# 1 agency with 1 program - sharing 1 contact
-# 1 agency with multiple programs - sharing 1 contact
-# 1 agency with 1 program - 2 contacts
-# 1 agency with multiple programs - multiple contacts, including ac
-# 1 agency with multiple programs - multiple contacts, excluding ac
-# 1 agency with no programs - make sure this doesn't break anything
-
-# Use above descriptions as the agency name.
-
-#TODO:
-#Exclude unknowns. First, we probably want to standardize markers for unknowns in current data.
-
-{
-    my $dbh = MVHub::Utils::DB::get_dbh();
-
-    # Fetch all agencies.
-    my $sql = MVHub::Utils::DB::get_sql_select_statement('AGENCY_X_ALL');
-
-    my $agencies_aref = $dbh->selectall_arrayref( $sql, { Slice => {} } );
-
-    # For each agency:
-    #    - extract identifying contact info (i.e. contact_first_name,
-    #      contact_last_name, and contact_email)
-    #    - Fetch all its programs into 2 distinct groups:
-    #       - (group 1): those with same contact as agency
-    #       - (group 2): those with different contact than agency contact
-
-    foreach my $agency_href (@$agencies_aref) {
-        my $agency_id     = $agency_href->{agency_id};
-        my $password      = $agency_href->{password};
-        my $agency_name   = $agency_href->{agency_name};
-        my $ac_first_name = $agency_href->{contact_first_name};
-        my $ac_last_name  = $agency_href->{contact_last_name};
-        my $ac_email      = $agency_href->{contact_email};
-
-        my $quick_login_id = MVHub::Common::encode_quick_login_id($agency_id);
-
-  # GET THE DATA FOR THE AGENCY CONTACT EMAIL
-  # Get the program names for this agency that ARE owned by the agency contact
-        my $sql = MVHub::Utils::DB::get_sql_select_statement(
-            'PROGRAM_X_PROGRAM_NAME');
-
-        my @names_of_programs_owned_by_ac = @{
-            $dbh->selectcol_arrayref(
-                $sql,           undef,         $agency_id,
-                $ac_first_name, $ac_last_name, $ac_email
-            )
-            };
-
-   # Get the programs for this agency that are NOT owned by the agency contact
-        $sql = MVHub::Utils::DB::get_sql_select_statement(
-            'PROGRAM_X_PROGRAM_CONTACT_FIRST_LAST_NAME_EMAIL');
-
-        my @programs_owned_by_pcs = @{
-            $dbh->selectall_arrayref(
-                $sql, { Slice => {} }, $agency_id,
-                $ac_first_name, $ac_last_name, $ac_email
-            )
-            };
-
-        send_welcome_to_ac( $ac_first_name, $agency_name, $password,
-            $quick_login_id, \@names_of_programs_owned_by_ac,
-            \@programs_owned_by_pcs, $ac_email );
-
-        if ( !@names_of_programs_owned_by_ac && !@programs_owned_by_pcs ) {
-
-           #TODO: whom should we be warning: ourselves or the agency contact?!
-            warn("The [$agency_name] agency has no programs!");
-        }
-
-        # EMAIL THE PROGRAM CONTACT(S), if any
-        next if !@programs_owned_by_pcs;
-
-# Get the program contacts (who are not also the agency contact) for our agency
-        $sql = MVHub::Utils::DB::get_sql_select_statement(
-            'PROGRAM_X_DISTINCT_PROGRAM_CONTACT_FIRST_LAST_NAME_EMAIL');
-
-        my $pcs_aref = $dbh->selectall_arrayref( $sql, { Slice => {} },
-            $agency_id, $ac_first_name, $ac_last_name, $ac_email );
-
-        # Get the program name(s) owned by this program contact
-        foreach my $pc_href (@$pcs_aref) {
-            $sql = MVHub::Utils::DB::get_sql_select_statement(
-                'PROGRAM_X_PROGRAM_NAME');
-
-            my $program_names_aref = $dbh->selectall_arrayref(
-                $sql,
-                { Slice => {} },
-                $agency_id,
-                $pc_href->{contact_first_name},
-                $pc_href->{contact_last_name},
-                $pc_href->{contact_email}
-            );
-
-            send_welcome_to_pc(
-                $agency_name, $password, $quick_login_id,
-                $pc_href,     $program_names_aref
-            );
-        }
-
-    }    # end of: for each agency
-    print("welcome_email.pl execution completed successfully.\n");
-}
-
-# Either of the program arefs could be empty. If both are empty, we have an
-# agency without a program. Issue a warning.
-sub send_welcome_to_ac {
-    my ($ac_first_name,                      $agency_name,
-        $password,                           $quick_login_id,
-        $names_of_programs_owned_by_ac_aref, $programs_owned_by_pcs_aref,
-        $ac_email_address
-    ) = @_;
-
-    my $subject
-        = "$ac_first_name, please update your $agency_name information";
-    my $names_of_programs_owned_by_ac;
-    if ( @$names_of_programs_owned_by_ac_aref == 1 ) {
-        $names_of_programs_owned_by_ac
-            = "($$names_of_programs_owned_by_ac_aref[0])";
-    }
-    elsif ( @$names_of_programs_owned_by_ac_aref > 1 ) {
-        $names_of_programs_owned_by_ac = ":\n\t - "
-            . join( "\n\t - ", @$names_of_programs_owned_by_ac_aref ) . "\n";
-    }
-
-    my $tmpl = HTML::Template->new( filename => $AGENCY_EMAIL_TEMPLATE )
-        or die "Failed to open $AGENCY_EMAIL_TEMPLATE template";
-    $tmpl->param(
-        first_name               => $ac_first_name,
-        agency_name              => $agency_name,
-        agency_contacts_programs => $names_of_programs_owned_by_ac,
-        other_programs_loop      => $programs_owned_by_pcs_aref,
-        password                 => $password,
-        quick_login_id           => $quick_login_id,
-        contact_us_email         => $MVHub::Common::HUB_EMAIL,
-        contact_us_phone         => $MVHub::Common::HUB_PHONE,
-        signer                   => $MVHub::Common::HUB_ADMIN_NAME,
-        team_name                => $MVHub::Common::HUB_TEAM_NAME
-    );
-    my $body = $tmpl->output();
-    remove_excess_blank_lines( \$body );
-    send_email( $ac_email_address, $subject, $body );
-}
-
-sub send_welcome_to_pc {
-    my ($agency_name, $password, $quick_login_id,
-        $pc_href,     $program_names_aref
-    ) = @_;
-    my $pc_first_name = $pc_href->{contact_first_name};
-    my $subject
-        = "$pc_first_name, please update your $agency_name information";
-    my $tmpl = HTML::Template->new( filename => $PROGRAM_EMAIL_TEMPLATE )
-        or die "Failed to open $PROGRAM_EMAIL_TEMPLATE template";
-
-    $tmpl->param(
-        first_name       => $pc_first_name,
-        agency_name      => $agency_name,
-        programs_loop    => $program_names_aref,
-        password         => $password,
-        quick_login_id   => $quick_login_id,
-        contact_us_email => $MVHub::Common::HUB_EMAIL,
-        contact_us_phone => $MVHub::Common::HUB_PHONE,
-        signer           => $MVHub::Common::HUB_ADMIN_NAME,
-        team_name        => $MVHub::Common::HUB_TEAM_NAME
-    );
-    my $body = $tmpl->output();
-    remove_excess_blank_lines( \$body );
-    send_email( $pc_href->{contact_email}, $subject, $body );
-}
-
-sub remove_excess_blank_lines {
-    my $body_ref = shift;
-    $$body_ref =~ s/\n\s*\n\s*\n/\n\n/;
-}
-
-sub send_email {
-    my ( $to_address, $subject, $body ) = @_;
-
-    # Generate e-mail headers
-    my $top = MIME::Entity->build(
-        Type    => 'text/plain',
-        From    => $MVHub::Common::HUB_ADMIN_NAME_AND_EMAIL,
-        To      => $to_address,
-        Subject => $subject,
-        Data    => $body
-    );
-
-    print $top->as_string;
-    MVHub::Common::sendmail($top);
-}

=== modified file 'app-mvhub/conf/sql_select.lib'
--- app-mvhub/conf/sql_select.lib	2010-07-11 20:16:47 +0000
+++ app-mvhub/conf/sql_select.lib	2010-07-14 18:53:41 +0000
@@ -342,6 +342,7 @@
       agency_id, 
       agency_name, 
       ( agency_name || ' (Main Agency Record)' ) AS record_name, 
+      quick_login_passwd,
       contact_first_name, 
       contact_last_name, 
       contact_email,
@@ -372,6 +373,7 @@
 FROM agency 
 WHERE agency_id = ?
 
+<<<<<<< TREE
 [AGENCY_X_PASSWORD]
 SELECT password
 FROM agency
@@ -383,6 +385,26 @@
 WHERE p.agency_id = a.agency_id
 ORDER BY p.date_created;
 
+=======
+[AGENCY_X_QUICK_LOGIN_MATCH]
+SELECT 
+      true 
+FROM 
+      agency 
+WHERE 
+      agency_id = ? 
+AND
+      quick_login_passwd = ?
+
+[AGENCY_X_QUICK_LOGIN_PASSWD]
+SELECT
+      quick_login_passwd
+FROM
+      agency
+WHERE
+      agency_id = ?
+
+>>>>>>> MERGE-SOURCE
 [AGENCY_X_SEARCH_WITH_TERMS]
 SELECT 
   agency_id, agency_name, agency_alias, address1, address2,
@@ -716,6 +738,7 @@
    SELECT 
       a.agency_id, 
       a.agency_name,
+      a.quick_login_passwd,
       a.contact_email as agency_contact_email,
       a.email, 
       p.program_name AS record_name, 

=== removed file 'app-mvhub/conf/templates/text/snailmail_agency_welcome.tmpl'
--- app-mvhub/conf/templates/text/snailmail_agency_welcome.tmpl	2009-07-01 16:01:13 +0000
+++ app-mvhub/conf/templates/text/snailmail_agency_welcome.tmpl	1970-01-01 00:00:00 +0000
@@ -1,43 +0,0 @@
-<p><b>FROM: <!--TMPL_VAR name="signer"-->, MVHub.com</b></p>
-
-<p><b>TO: <!--TMPL_VAR name="first_name"--> <!--TMPL_VAR name="last_name"-->, <!--TMPL_VAR name="agency_name"--></b></p>
-
-<p>Dear <!--TMPL_VAR name="first_name"-->,</p>
-
-<p><b>We need you to update your agency's records at MVHub.com's on-line Community Services Directory</b>.</p>
-
-<p><b>Every day</b>, residents and professionals throughout the Merrimack Valley use the Directory to find information on <b>over 300 local, non-profit programs</b> provided by organizations like yours.</p>
-    
-<p>To ensure that they get the most accurate information about your organization, I'm asking you to log-in to the website, and review & update your organization's records as soon as possible.</p>
-
-<p>MVHub.com has been re-designed, but rest assured, <b>it remains non-profit and free</b>. We will never try to sell you anything. Our only goal is connecting people in need to helpful community services like yours.</p>
-
-<p>INSTRUCTIONS:</p>
-
-<p>1) Go to the website: <u>directory.mvhub.com</u></p>
-
-<p>2) Click on <u>Agency log-in</u> in the left menu bar.</p>
-
-<p>3) Select your agency <u>(<!--TMPL_VAR name="agency_name"-->)</u> from the list, and enter your new password (<b><!--TMPL_VAR name="password"--></b>) and press the <u>Log-in</u> button.</p>
-
-<p>4) Select <u>Update</u> for your Agency Record and follow the instructions.</p>
-
-<!--TMPL_IF name="agency_contacts_programs"-->
-<p>5) Select <u>Update</u> and follow the instructions for each Program Record for which you are the principal contact <!--TMPL_VAR name="agency_contacts_programs"--></p>
-<!--/TMPL_IF-->
-
-<!--TMPL_IF name="other_programs_loop"-->
-<p>We have also asked the following contacts(s) for these other programs(s) offered by your agency to update their Program Record(s):</p>
-   <!--TMPL_LOOP name="other_programs_loop"-->
-   &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<b><!--TMPL_VAR name="program_name"-->: <!--TMPL_VAR name="contact_first_name"--> <!--TMPL_VAR name="contact_last_name"--></b> (<!--TMPL_VAR name="contact_email"-->)<br>
-   <!--/TMPL_LOOP-->
-</p>If you need to change any of these program contact(s), you may also do so at the site. (Note: the above password has been shared with these contact(s).)</p>
-<!--/TMPL_IF-->
-
-<p><b>If you have any questions, concerns, or difficulties</b> (or if you are not the correct contact for this agency), please contact me at <b><!--TMPL_VAR name="contact_us_email"--></b> or <b><!--TMPL_VAR name="contact_us_phone"--></b> as soon as possible. I'll get back to you within 2 business days.</p>
-
-<b>Thanks so much,</b><br><br><br><br>
-
-<!--TMPL_VAR name="signer"--><br>
-<!--TMPL_VAR name="team_name"--><br>
-:::PAGEBREAK:::

=== removed file 'app-mvhub/conf/templates/text/snailmail_program_welcome.tmpl'
--- app-mvhub/conf/templates/text/snailmail_program_welcome.tmpl	2009-07-01 16:01:13 +0000
+++ app-mvhub/conf/templates/text/snailmail_program_welcome.tmpl	1970-01-01 00:00:00 +0000
@@ -1,36 +0,0 @@
-<p><b>FROM: <!--TMPL_VAR name="signer"-->, MVHub.com</b></p>
-
-<p><b>TO: <!--TMPL_VAR name="first_name"--> <!--TMPL_VAR name="last_name"-->, <!--TMPL_VAR name="agency_name"--></b></p>
-
-<p>Dear <!--TMPL_VAR name="first_name"-->,</p>
-
-<p><b>We need you to update your program records at MVHub.com's on-line Community Services Directory</b>.</p>
-
-<p><b>Every day</b>, residents and non-profit personnel throughout the Merrimack Valley use the Directory to find information on <b>over 300 local, non-profit programs</b> like yours.</p>
-    
-<p>We still have you listed as the primary contact for the following <!--TMPL_VAR name="agency_name"--> program(s):<br>
-<!--TMPL_LOOP name="programs_loop"-->
-    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<b><!--TMPL_VAR name="program_name"--></b><br>
-<!--/TMPL_LOOP-->
-
-<p>To ensure that Directory users get the most accurate information about your program(s), I'm asking you to log-in to the website and review & update your program records as soon as possible. </p> 
-
-<p>MVHub.com has been re-designed, but rest assured, <b>it remains non-profit and free</b>. We will never try to sell you anything. Our only goal is connecting people in need to helpful community services like yours.</p>
-
-<p>INSTRUCTIONS:</p>
-
-<p>1) Go to the website: <u>directory.mvhub.com</u></p>
-
-<p>2) Click on <u>Agency log-in</u> in the left menu bar.</p>
-
-<p>3) Select your agency (<u><!--TMPL_VAR name="agency_name"--></u>) from the list, and enter your new password (<b><!--TMPL_VAR name="password"--></b>) and press the <u>Log-in</u> button.</p>
-
-<p>4) Select <u>Update</u> for each of your Program Record(s), and follow the instructions.</p>
-
-<p><b>If you have any questions, concerns, or difficulties</b> (or if you are not the correct contact for these program(s)), please contact at <b><!--TMPL_VAR name="contact_us_email"--></b> or <b><!--TMPL_VAR name="contact_us_phone"--></b> as soon as possible. I'll get back to you within 2 business days.</p>
-
-<b>Thanks so much,</b><br><br><br><br><br>
-
-<!--TMPL_VAR name="signer"--><br>
-<!--TMPL_VAR name="team_name"--><br>
-:::PAGEBREAK:::

=== removed file 'app-mvhub/conf/templates/text/welcome_agency_email.tmpl'
--- app-mvhub/conf/templates/text/welcome_agency_email.tmpl	2009-07-01 16:01:13 +0000
+++ app-mvhub/conf/templates/text/welcome_agency_email.tmpl	1970-01-01 00:00:00 +0000
@@ -1,34 +0,0 @@
-Hi <!--TMPL_VAR name="first_name"-->,
-
-You are our contact at <!--TMPL_VAR name="agency_name"-->.
-
-We need you to update your organization's information at MVHub.com non-profit  Community Services Directory. 
-
-Every day, more than 175 people throughout the Merrimack Valley 
-use the Directory to find information on over 600 programs.
-
-We've given your organization an account, allowing you to log-in and directly 
-review & edit the information they read about your organization.
-
-MVHub.com is non-profit and free. We will never try to sell you anything. Our 
-goal is to connect people in need to helpful community services like yours.
-
-<!--TMPL_IF name="agency_contacts_programs"-->3) Select the 'Update' link for each Program Record <!--TMPL_VAR name="agency_contacts_programs"--> showing your name as the Contact, and follow the directions.<!--/TMPL_IF-->
-
-TO LOG-IN  Click on:
-         http://mvhub.com/cgi-bin/mvhub/agency.pl?rm=ql&id=<!--TMPL_VAR name="quick_login_id"-->
-
-If you have any questions, concerns, or difficulties (or if you are not the correct contact for this agency), please contact me at <!--TMPL_VAR name="contact_us_email"--> or <!--TMPL_VAR name="contact_us_phone"--> as soon as possible. I'll get back to you within 2 business days.
-
-<!--TMPL_IF name="other_programs_loop"-->
-We have also asked the following Program Contacts(s) 
-to update your agency's other Program Record(s):
-   <!--TMPL_LOOP name="other_programs_loop"-->
-     <!--TMPL_VAR name="program_name"-->: <!--TMPL_VAR name="contact_first_name"--> <!--TMPL_VAR name="contact_last_name"--> (<!--TMPL_VAR name="contact_email"-->)
-   <!--/TMPL_LOOP-->
-If you need to change any of these program contact(s), you may do so at the website as well.
-<!--/TMPL_IF-->
-
-Thanks so much,
-<!--TMPL_VAR name="signer"-->
-<!--TMPL_VAR name="team_name"-->

=== removed file 'app-mvhub/conf/templates/text/welcome_program_email.tmpl'
--- app-mvhub/conf/templates/text/welcome_program_email.tmpl	2009-07-01 16:01:13 +0000
+++ app-mvhub/conf/templates/text/welcome_program_email.tmpl	1970-01-01 00:00:00 +0000
@@ -1,26 +0,0 @@
-Hi <!--TMPL_VAR name="first_name"-->,
-
-You are our  primary contact for the following <!--TMPL_VAR name="agency_name"--> program(s): 
-<!--TMPL_LOOP name="programs_loop"-->
-       <!--TMPL_VAR name="program_name"-->
-   <!--/TMPL_LOOP-->
-
-We need you to update your program information at MVHub.com's on-line Community Services Directory. 
-
-Every day, more than 175 people use the Directory to find 
-information on more than 600 local, non-profit programs.
-
-We've given your organization an account, allowing you to log-in and directly review & edit your information.
-
-MVHub.com is non-profit and free. We will never try to sell you anything. Our 
-goal is to connect people in need to helpful community services like yours.
-
-
-TO LOG-IN  Click on:
-         http://mvhub.com/cgi-bin/mvhub/agency.pl?rm=ql&id=<!--TMPL_VAR name="quick_login_id"-->
-
-If you have any questions, concerns, or difficulties (or if you are not the correct contact for this agency), please contact me at <!--TMPL_VAR name="contact_us_email"--> or <!--TMPL_VAR name="contact_us_phone"--> as soon as possible. I'll get back to you within 2 business days.
-
-Thanks so much,
-<!--TMPL_VAR name="signer"-->
-<!--TMPL_VAR name="team_name"-->

=== added file 'app-mvhub/setup/database/sql/009_create_quick_login_passwd_column.sql'
--- app-mvhub/setup/database/sql/009_create_quick_login_passwd_column.sql	1970-01-01 00:00:00 +0000
+++ app-mvhub/setup/database/sql/009_create_quick_login_passwd_column.sql	2010-07-14 18:53:41 +0000
@@ -0,0 +1,8 @@
+--add version number and note before you add the other sql
+BEGIN;
+INSERT INTO version_log ( version,note ) 
+	VALUES (9,'added the quick_login_passwd column to the agency table');
+
+ALTER TABLE agency ADD COLUMN quick_login_passwd text DEFAULT lpad(to_hex(CAST(random()*4294967295 AS INTEGER)), 8, '0');
+
+COMMIT;

=== modified file 'app-mvhub/setup/etc/apache2/sites-available/mvhub.conf'
--- app-mvhub/setup/etc/apache2/sites-available/mvhub.conf	2010-06-28 20:13:48 +0000
+++ app-mvhub/setup/etc/apache2/sites-available/mvhub.conf	2010-07-14 18:53:41 +0000
@@ -30,7 +30,7 @@
        CustomLog /var/www/mvhub/$USER/log/$SITE/referer.log referer
        CustomLog /var/www/mvhub/$USER/log/$SITE/combined.log combined 
        
-       ScriptAlias /cgi-bin/ /var/www/mvhub/$USER/link-to-live-code/app-mvhub/DocumentRoot/cgi-bin/ 
+       ScriptAlias /cgi-bin /var/www/mvhub/$USER/link-to-live-code/app-mvhub/DocumentRoot/cgi-bin/ 
        <Directory  /var/www/mvhub/$USER/link-to-live-code/app-mvhub/cgi-bin/>
          Options IncludesNOEXEC ExecCGI
        </Directory>
@@ -69,7 +69,13 @@
           DefaultInitEnv PERL5LIB             /var/www/mvhub/$USER/link-to-live-code/lib-mvhub/lib/
           DefaultInitEnv USER                 $USER
        </ifmodule>
-                                                                                             
+
+	# Use mod_rewrite to make shorter quick-login URLs to send to agencies
+       <IfModule mod_rewrite.c>
+	RewriteEngine on
+	RewriteRule ^/(\d{6})/(\w{8})/?$ /cgi-bin/mvhub/agency.pl?rm=ql&aid=$1&qlid=$2 [PT]
+       </IfModule>
+                                                                                           
        # Since .htaccess files don't work in the cgi-bin.
        <Directory  /var/www/mvhub/$USER/link-to-live-code/app-mvhub/DocumentRoot/cgi-bin/admin/>
           AuthType Basic

=== modified file 'app-mvhub/t/bugs/categorize_link_missing_when_agency_login.t'
--- app-mvhub/t/bugs/categorize_link_missing_when_agency_login.t	2009-06-22 19:09:14 +0000
+++ app-mvhub/t/bugs/categorize_link_missing_when_agency_login.t	2010-07-14 18:53:41 +0000
@@ -9,6 +9,8 @@
 use Test::More;
 use Test::WWW::Mechanize;
 
+use MVHub::Utils::Setup;
+
 BEGIN {
     use FindBin qw($Bin);
     chdir $Bin;
@@ -16,8 +18,17 @@
 use TestHelper;
 
 {    #main
-    my $host            = TestHelper::get_test_website_name('mvh');
-    my @pages           = init_pages($host);
+    my $host     = TestHelper::get_test_website_name('mvh');
+    my $base_cfg = MVHub::Utils::ConfigSimple::create_config_from(
+        $ENV{MV_CONFIG_FILE} );
+    my $config_filename
+        = MVHub::Utils::Setup::determine_user_config_filename_from(
+        $ENV{USER}, 'mvh', $base_cfg );
+    my $agency_id = '102695';
+    my $quick_login_id
+        = TestHelper::get_quick_login_from( $agency_id, $config_filename );
+
+    my @pages = init_pages( $host, $agency_id, $quick_login_id );
     my $number_of_tests = ( ( scalar @pages ) * 4 );
 
     plan tests => $number_of_tests;
@@ -31,9 +42,13 @@
 sub init_pages {
     my $host = shift
         or die 'init_pages() missing param: host';
+    my $agency_id = shift or die 'init_pages() missing param: agency_id';
+    my $quick_login_id = shift
+        or die 'init_pages() missing param: quick_login_id';
+
     my @pages = (
         {   'url' =>
-                "http://$host/cgi-bin/mvhub/agency.pl?rm=ql&id=10546275370";,
+                "http://$host/cgi-bin/mvhub/agency.pl?rm=ql&aid=$agency_id&qlid=$quick_login_id";,
             'expected_content' =>
                 "Agency Account Home Page - Lowell Public Schools",
             'tests_to_skip' => '',

=== modified file 'app-mvhub/t/bugs/ql_display_agency_home_interaction.t'
--- app-mvhub/t/bugs/ql_display_agency_home_interaction.t	2009-09-15 01:12:17 +0000
+++ app-mvhub/t/bugs/ql_display_agency_home_interaction.t	2010-07-14 18:53:41 +0000
@@ -9,6 +9,8 @@
 use Test::More;
 use Test::WWW::Mechanize;
 
+use MVHub::Utils::Setup;
+
 BEGIN {
     use FindBin qw($Bin);
     chdir $Bin;
@@ -16,8 +18,17 @@
 use TestHelper;
 
 {    #main
-    my $host            = TestHelper::get_test_website_name('mvh');
-    my @pages           = init_pages($host);
+    my $host     = TestHelper::get_test_website_name('mvh');
+    my $base_cfg = MVHub::Utils::ConfigSimple::create_config_from(
+        $ENV{MV_CONFIG_FILE} );
+    my $config_filename
+        = MVHub::Utils::Setup::determine_user_config_filename_from(
+        $ENV{USER}, 'mvh', $base_cfg );
+    my $agency_id = '102695';
+    my $quick_login_id
+        = TestHelper::get_quick_login_from( $agency_id, $config_filename );
+
+    my @pages = init_pages( $host, $agency_id, $quick_login_id );
     my $number_of_tests = ( ( scalar @pages ) * 3 );
 
     plan tests => $number_of_tests;
@@ -31,9 +42,13 @@
 sub init_pages {
     my $host = shift
         or die 'init_pages() missing param: $host';
+    my $agency_id = shift or die 'init_pages() missing param: $agency_id';
+    my $quick_login_id = shift
+        or die 'init_pages() missing param: $quick_login_id';
+
     my @pages = (
         {   'url' =>
-                "http://$host/cgi-bin/mvhub/agency.pl?rm=ql&id=10546275370";,
+                "http://$host/cgi-bin/mvhub/agency.pl?rm=ql&aid=$agency_id&qlid=$quick_login_id";,
             'expected_content' =>
                 "Agency Account Home Page - Lowell Public Schools",
             'tests_to_skip' => '',

=== modified file 'app-mvhub/t/bugs/ql_works_after_admin_login.t'
--- app-mvhub/t/bugs/ql_works_after_admin_login.t	2009-06-09 16:11:27 +0000
+++ app-mvhub/t/bugs/ql_works_after_admin_login.t	2010-07-14 18:53:41 +0000
@@ -9,6 +9,8 @@
 use Test::More;
 use Test::WWW::Mechanize;
 
+use MVHub::Utils::Setup;
+
 BEGIN {
     use FindBin qw($Bin);
     chdir $Bin;
@@ -17,8 +19,17 @@
 use TestHelper;
 
 {    #main
-    my $host            = TestHelper::get_test_website_name('mvh');
-    my @pages           = init_pages($host);
+    my $host     = TestHelper::get_test_website_name('mvh');
+    my $base_cfg = MVHub::Utils::ConfigSimple::create_config_from(
+        $ENV{MV_CONFIG_FILE} );
+    my $config_filename
+        = MVHub::Utils::Setup::determine_user_config_filename_from(
+        $ENV{USER}, 'mvh', $base_cfg );
+    my $agency_id = '102695';
+    my $quick_login_id
+        = TestHelper::get_quick_login_from( $agency_id, $config_filename );
+
+    my @pages = init_pages( $host, $agency_id, $quick_login_id );
     my $number_of_tests = ( ( scalar @pages ) * 3 );
 
     plan tests => $number_of_tests;
@@ -31,6 +42,10 @@
 sub init_pages {
     my $host = shift
         or die 'init_pages() missing param: $host';
+    my $agency_id = shift or die 'init_pages() missing param: $agency_id';
+    my $quick_login_id = shift
+        or die 'init_pages() missing param: $quick_login_id';
+
     my @pages = (
         {   'url'              => "http://$host/html/admin/home.shtml";,
             'expected_content' => "Welcome to the Administrative Home Page",
@@ -38,7 +53,7 @@
             'skip_reason'      => '',
         },
         {   'url' =>
-                "http://$host/cgi-bin/mvhub/agency.pl?rm=ql&id=10546275370";,
+                "http://$host/cgi-bin/mvhub/agency.pl?rm=ql&aid=$agency_id&qlid=$quick_login_id";,
             'expected_content' =>
                 "Agency Account Home Page - Lowell Public Schools",
             'tests_to_skip' => '',

=== modified file 'app-mvhub/t/mech/pages.t'
--- app-mvhub/t/mech/pages.t	2010-07-12 17:52:47 +0000
+++ app-mvhub/t/mech/pages.t	2010-07-14 18:53:41 +0000
@@ -9,6 +9,8 @@
 use Test::More;
 use Test::WWW::Mechanize;
 
+use MVHub::Utils::Setup;
+
 BEGIN {
     use FindBin qw($Bin);
     chdir $Bin;
@@ -17,13 +19,31 @@
 use TestHelper;
 
 {    #main
-    my $host                = TestHelper::get_test_website_name('mvh');
+    my $host = TestHelper::get_test_website_name('mvh');
+
+    my $base_cfg = MVHub::Utils::ConfigSimple::create_config_from(
+        $ENV{MV_CONFIG_FILE} );
+    my $config_filename
+        = MVHub::Utils::Setup::determine_user_config_filename_from(
+        $ENV{USER}, 'mvh', $base_cfg );
+    my $agency_id = '102695';
+    my $quick_login_id
+        = TestHelper::get_quick_login_from( $agency_id, $config_filename );
+
     my @mvh_pages_from_both = init_pages_for_both($host);
-    my @pages_for_mvh       = init_pages_for_mvh_only($host);
+    my @pages_for_mvh
+        = init_pages_for_mvh_only( $host, $agency_id, $quick_login_id );
 
     $host = TestHelper::get_test_website_name('nsp');
+    $config_filename
+        = MVHub::Utils::Setup::determine_user_config_filename_from(
+        $ENV{USER}, 'nsp', $base_cfg );
+    $agency_id = '103520';
+    $quick_login_id = get_quick_login_from( $agency_id, $config_filename );
+
     my @nsp_pages_from_both = init_pages_for_both($host);
-    my @pages_for_nsp       = init_pages_for_nsp_only($host);
+    my @pages_for_nsp
+        = init_pages_for_nsp_only( $host, $agency_id, $quick_login_id );
 
     my @total_pages = (
         @mvh_pages_from_both, @pages_for_mvh,
@@ -100,9 +120,16 @@
             'tests_to_skip'    => '',
             'skip_reason'      => '',
         },
+        {   'url' =>
+                "http://$host/cgi-bin/mvhub/agency.pl?rm=ql&aid=00&qlid=00";,
+            'expected_content' =>
+                "Invalid quick log-in ID, please log in manually",
+            'tests_to_skip' => '',
+            'skip_reason'   => '',
+        },
         {   'url' => "http://$host/cgi-bin/mvhub/agency.pl?rm=ql&id=00";,
             'expected_content' =>
-                "Invalid quick log-in ID, please log in manually",
+                "You used an old login URL that is no longer valid",
             'tests_to_skip' => '',
             'skip_reason'   => '',
         },
@@ -113,9 +140,19 @@
 sub init_pages_for_mvh_only {
     my $host = shift
         or die 'init_pages() missing param: $host';
+    my $agency_id = shift or die 'init_pages() missing param: $agency_id';
+    my $quick_login_id = shift
+        or die 'init_pages() missing param: $quick_login_id';
+
     my @pages = (
+        {   'url' => "http://$host/$agency_id/$quick_login_id";,
+            'expected_content' =>
+                "Agency Account Home Page - Lowell Public Schools",
+            'tests_to_skip' => '',
+            'skip_reason'   => '',
+        },
         {   'url' =>
-                "http://$host/cgi-bin/mvhub/agency.pl?rm=ql&id=10546275370";,
+                "http://$host/cgi-bin/mvhub/agency.pl?rm=ql&aid=$agency_id&qlid=$quick_login_id";,
             'expected_content' =>
                 "Agency Account Home Page - Lowell Public Schools",
             'tests_to_skip' => '',
@@ -164,6 +201,10 @@
 sub init_pages_for_nsp_only {
     my $host = shift
         or die 'init_pages() missing param: $host';
+    my $agency_id = shift or die 'init_pages() missing param: $agency_id';
+    my $quick_login_id = shift
+        or die 'init_pages() missing param: $quick_login_id';
+
     my @pages = (
         {   'url' =>
                 "http://$host/cgi-bin/mvhub/agency.pl?rm=display_agency_home&agency_id=103542";,
@@ -198,7 +239,7 @@
             'skip_reason'   => '',
         },
         {   'url' =>
-                "http://$host/cgi-bin/mvhub/agency.pl?rm=ql&id=10716402745";,
+                "http://$host/cgi-bin/mvhub/agency.pl?rm=ql&aid=$agency_id&qlid=$quick_login_id";,
             'expected_content' =>
                 "Agency Account Home Page - North Shore Community Action Programs, Inc.",
             'tests_to_skip' => '',

=== modified file 'app-mvhub/t/sql_lib_sanity.t'
--- app-mvhub/t/sql_lib_sanity.t	2010-07-10 19:12:23 +0000
+++ app-mvhub/t/sql_lib_sanity.t	2010-07-14 18:53:41 +0000
@@ -11,6 +11,8 @@
 use Test::NoWarnings;
 use MVHub::Utils::DB qw/get_dbh/;
 
+use TestHelper;
+
 my $SQL_LIB_FILE
     = "/var/www/mvhub/$ENV{USER}/link-to-live-code/app-mvhub/conf/sql_select.lib";
 my $NUM_MISC_TESTS = 2;
@@ -22,10 +24,14 @@
 
     statements_in_alphabetical_order_in($SQL_LIB_FILE);
 
-    my $dbh = MVHub::Utils::DB::get_dbh( $ENV{'MV_CONFIG_FILE'} );
+    my $dbh            = MVHub::Utils::DB::get_dbh( $ENV{'MV_CONFIG_FILE'} );
+    my $agency_id      = '103553';
+    my $quick_login_id = TestHelper::get_quick_login_from( $agency_id,
+        $ENV{'MV_CONFIG_FILE'} );
 
     statements_without_placeholders_do_ok_in( $sql_lib, $dbh );
-    my $test_placeholders_ref = get_test_placeholders();
+    my $test_placeholders_ref
+        = get_test_placeholders( $agency_id, $quick_login_id );
     statements_with_placeholders_do_ok_in( $sql_lib, $dbh,
         $test_placeholders_ref );
 }    #main
@@ -36,6 +42,9 @@
 }
 
 sub get_test_placeholders {
+    my $agency_id      = shift or die 'missing param: agency_id';
+    my $quick_login_id = shift or die 'missing param: quick_login_id';
+
     my %data = (
         'AGENCY_HEADING_PROGRAM_X_AGENCY_ID'       => ['103553'],
         'AGENCY_HEADING_PROGRAM_X_AGENCY_ID_EQUAL' => ['103553'],
@@ -63,7 +72,9 @@
         'AGENCY_X_PASSWORD'                         => [103586],
         'AGENCY_PROGRAM_X_AGENCY_NAME_AGENCY_ALIAS' => [510296],
         'AGENCY_X_LAST_UPDATED'                     => [103553],
-        'ALIAS_X_ALIAS_NAME'                        => [1],
+        'AGENCY_X_QUICK_LOGIN_MATCH'  => [ $agency_id, $quick_login_id ],
+        'AGENCY_X_QUICK_LOGIN_PASSWD' => [$agency_id],
+        'ALIAS_X_ALIAS_NAME'          => [1],
         'ALL_NAMES_VIEW_CATS_WITH_VISIBLE_PROGRAMS_VIEW_X_ALL_FOR_SYNONYMS' =>
             ['[[:<:]](ymca|counsel|immi|shelter)[[:>:]]'],
         'CATEGORY_X_EXISTS_ONE_CATEGORY_NAME'        => ['cat'],

=== modified file 'lib-mvhub/lib/MVHub/AgencyAccount.pm'
--- lib-mvhub/lib/MVHub/AgencyAccount.pm	2010-07-09 17:32:27 +0000
+++ lib-mvhub/lib/MVHub/AgencyAccount.pm	2010-07-14 18:53:41 +0000
@@ -396,9 +396,13 @@
         = int $self->get_config_param('NOTIFICATION.expire_months');
     my $agency_needs_updating = has_expired( $last_update, 6 );
 
+    my $sql = MVHub::Utils::DB::get_sql_select_statement(
+        'AGENCY_X_QUICK_LOGIN_PASSWD');
+    my $ql_id = ( $dbh->selectrow_array( $sql, {}, $agency_id ) )[0];
+
     $template->param(
         'QUICK_LOGIN_URL' => MVHub::Utils::generate_quick_login_url(
-            $ENV{HTTP_HOST}, $agency_id
+            $ENV{HTTP_HOST}, $agency_id, $ql_id
         ),
         $AH_AGENCY_ID_TAG   => $agency_id,
         $AH_MESSAGE_TAG     => $message,
@@ -515,6 +519,7 @@
 # The ql runmode can be used from a hyper-link where we want to log-in a user in one click,
 # e.g. from within an email.
 sub ql {
+<<<<<<< TREE
     my $self           = shift;
     my $cgi            = $self->query();
     my $quick_login_id = $cgi->param('id');
@@ -522,34 +527,48 @@
     my $agency_id = decode_quick_login_id($quick_login_id);
     if ( int($agency_id) == $agency_id ) {
 
+=======
+    my $self               = shift;
+    my $cgi                = $self->query();
+    my $dbh                = $self->dbh();
+    my $agency_id          = $cgi->param('aid');
+    my $quick_login_id     = $cgi->param('qlid');
+    my $old_quick_login_id = $cgi->param('id');
+
+    my $sql = MVHub::Utils::DB::get_sql_select_statement(
+        'AGENCY_X_QUICK_LOGIN_MATCH');
+    my @bind_values = ( $agency_id, $quick_login_id );
+    my @is_valid = $dbh->selectrow_array( $sql, {}, @bind_values );
+
+    if ( $is_valid[0] ) {
+>>>>>>> MERGE-SOURCE
         my $cookie
             = MVHub::AuthAccount::init_session( caller_id => $agency_id );
         $self->header_add( -cookie => $cookie );
+<<<<<<< TREE
         $self->redirect( cgi_params_href => { rm => 'display_agency_home' } );
         return
             "Login successful - redirecting to agency $agency_id home page";
 
+=======
+        $self->param( 'agency_id', $agency_id );
+        return $self->display_agency_home();
+
+    }
+    elsif ($old_quick_login_id) {
+
+        return $self->old_quick_login_message();
+>>>>>>> MERGE-SOURCE
     }
     else {
-        $self->redirect(
-            cgi_params_href => {
-                rm => 'show_login_page',
-                error_code =>
-                    'Invalid quick log-in ID, please log in manually.'
-            }
-        );
-        return "Login failed. Redirecting back to login page.";
+        $self->param( 'login_error',
+            'Invalid quick log-in ID, please log in manually' );
+        return $self->show_login_page();
     }
 }
 
 ################ non run-mode functions #################
 
-# Returns agency id from a quick-login id
-sub decode_quick_login_id {
-    my $quick_login_id = shift;
-    return ( ( $quick_login_id - 12345 )**0.5 );
-}
-
 # Has the given last-updated date (in mm-dd-yyyy format) expired?
 sub has_expired {
     my ( $mdy_date, $expire_months ) = @_;
@@ -566,6 +585,27 @@
     return $age_duration->delta_months() >= $expire_months;
 }
 
+sub old_quick_login_message {
+    my $self        = shift;
+    my $admin_name  = $self->get_config_param('NOTIFICATION.admin_name');
+    my $admin_email = $self->get_config_param('NOTIFICATION.admin_email');
+    my $admin_phone = $self->get_config_param('NOTIFICATION.admin_phone');
+    return <<END;
+<p>Whoops! You used an old login URL that is no longer valid.</p>
+<p>On <b>July 12th, 2010</b>, we changed the way login URLs are generated. 
+The old way had a few security flaws that have now been corrected. Unfortunately, 
+this means that <b>any emails we sent you prior to July 12th, 2010 contains URLs 
+that are now INVALID</b>. You are at this page because you used one of our old 
+URLs that we sent.</p>
+<p>In order to login to your account, please ensure you are using a link in an email 
+that was sent after July 12th, 2010. If you are still having trouble please contact 
+us using the information below and we'll be happy to get you your correct login link.</p>
+$admin_name<br>
+$admin_email<br>
+$admin_phone<br>
+END
+}
+
 sub redirect {
     my $self = shift;
     my %args = @_;

=== modified file 'lib-mvhub/lib/MVHub/Common.pm'
--- lib-mvhub/lib/MVHub/Common.pm	2010-06-13 22:41:22 +0000
+++ lib-mvhub/lib/MVHub/Common.pm	2010-07-14 18:53:41 +0000
@@ -28,7 +28,6 @@
 our @EXPORT = qw(
     delimit_field
     display_agency_home_page_and_exit
-    encode_quick_login_id
     get_agency_select_list
     prepare_form
     sendmail
@@ -204,12 +203,6 @@
     );
 }
 
-# Creates a quick log-in id from an agency id
-sub encode_quick_login_id {
-    my $agency_id = shift;
-    return $agency_id**2 + 12345;
-}
-
 sub get_agency_select_list {
     my $dbh      = shift;
     my $size     = shift;

=== modified file 'lib-mvhub/lib/MVHub/Notifications.pm'
--- lib-mvhub/lib/MVHub/Notifications.pm	2010-04-03 18:33:59 +0000
+++ lib-mvhub/lib/MVHub/Notifications.pm	2010-07-14 18:53:41 +0000
@@ -43,10 +43,11 @@
     my $notice_href          = shift;
 
     my $tmpl = HTML::Template->new( filename => $template_file );
-    my $quick_login_url
-        = MVHub::Utils::generate_quick_login_url(
+    my $quick_login_url = MVHub::Utils::generate_quick_login_url(
         $email_constants_href->{website_name},
-        $notice_href->{agency_id} );
+        $notice_href->{agency_id},
+        $notice_href->{quick_login_passwd}
+    );
 
     $tmpl->param(
         first_name      => $notice_href->{contact_first_name},
@@ -136,6 +137,9 @@
         $notifications_for{$unique_id}{'agency_name'}
             = $expired_record_href->{'agency_name'};
 
+        $notifications_for{$unique_id}{'quick_login_passwd'}
+            = $expired_record_href->{'quick_login_passwd'};
+
         $notifications_for{$unique_id}{'contact_email'}
             = $expired_record_href->{'contact_email'};
 

=== modified file 'lib-mvhub/lib/MVHub/Utils.pm'
--- lib-mvhub/lib/MVHub/Utils.pm	2010-07-01 15:33:02 +0000
+++ lib-mvhub/lib/MVHub/Utils.pm	2010-07-14 18:53:41 +0000
@@ -15,7 +15,6 @@
     choose_default_or_custom_file
     clean_cgi_params
     die_if_missing_env_vars
-    encode_quick_login_id
     generate_quick_login_url
     mm_dd_yyyy_to_yyyy_mm_dd
     parse_zip_code
@@ -92,17 +91,12 @@
     }
 }
 
-# Creates a quick log-in id from an agency id
-sub encode_quick_login_id {
-    my $agency_id = shift or croak "Missing Param: agency_id";
-    return $agency_id**2 + 12345;
-}
-
 sub generate_quick_login_url {
     my $website_name = shift or croak "Missing Param: website_name\n";
     my $agency_id    = shift or croak "Missing Param: agency_id\n";
-    my $ql_id = encode_quick_login_id($agency_id);
-    return "http://${website_name}/cgi-bin/mvhub/agency.pl?rm=ql&id=$ql_id";;
+    my $ql_id        = shift or croak "Missing Param: ql_id\n";
+    return
+        "http://${website_name}/cgi-bin/mvhub/agency.pl?rm=ql&aid=${agency_id}&qlid=${ql_id}";;
 }
 
 sub parse_zip_code {

=== modified file 'lib-mvhub/lib/MVHub/Utils/Setup.pm'
--- lib-mvhub/lib/MVHub/Utils/Setup.pm	2010-07-08 22:37:52 +0000
+++ lib-mvhub/lib/MVHub/Utils/Setup.pm	2010-07-14 18:53:41 +0000
@@ -23,6 +23,7 @@
     @SITE_CODES
     add_apache_config
     add_dns
+    determine_user_config_filename_from
     get_dev_home_dirs
     get_dev_home_files
     get_production_data
@@ -181,21 +182,6 @@
     return $$role_rows_aref[0]{rolsuper} ? 1 : 0;
 }
 
-sub _determine_user_config_filename_from {
-    ( my $username, my $site_code, my $cfg ) = Params::Validate::validate_pos(
-        @_,
-        { type => SCALAR },
-        { type => SCALAR },
-        { can  => 'param' }
-    );
-
-    my $base_dir = $cfg->param('BASE.dir');
-
-    # Conf directory hard-coded - Least evil of available choices
-    # Less cumbersome then adding a conf_dir key in the config file.
-    return "$base_dir/$username/conf/$site_code.conf";
-}
-
 sub _do_or_die {
     ( my $cmd ) = Params::Validate::validate_pos( @_, { type => SCALAR }, );
 
@@ -378,8 +364,7 @@
 
     foreach my $prefix (@SITE_CODES) {
         my $update_user_cfg_filename
-            = _determine_user_config_filename_from( $username, $prefix,
-            $cfg );
+            = determine_user_config_filename_from( $username, $prefix, $cfg );
         my $update_user_cfg = MVHub::Utils::ConfigSimple::create_config_from(
             $update_user_cfg_filename);
         my $dbh = MVHub::Utils::DB::get_dbh($update_user_cfg_filename);
@@ -402,6 +387,21 @@
     }
 }
 
+sub determine_user_config_filename_from {
+    ( my $username, my $site_code, my $cfg ) = Params::Validate::validate_pos(
+        @_,
+        { type => SCALAR },
+        { type => SCALAR },
+        { can  => 'param' }
+    );
+
+    my $base_dir = $cfg->param('BASE.dir');
+
+    # Conf directory hard-coded - Least evil of available choices
+    # Less cumbersome then adding a conf_dir key in the config file.
+    return "$base_dir/$username/conf/$site_code.conf";
+}
+
 sub get_db_version {
     ( my $dbh )
         = Params::Validate::validate_pos( @_, { can => 'selectrow_array' }, );
@@ -561,8 +561,7 @@
     print "Loading production data...";
     foreach my $suffix (@SITE_CODES) {
         my $cfg_filename
-            = _determine_user_config_filename_from( $username, $suffix,
-            $cfg );
+            = determine_user_config_filename_from( $username, $suffix, $cfg );
         my $user_cfg
             = MVHub::Utils::ConfigSimple::create_config_from($cfg_filename);
 
@@ -591,8 +590,7 @@
     print "Loading test data...";
     foreach my $suffix (@SITE_CODES) {
         my $cfg_filename
-            = _determine_user_config_filename_from( $username, $suffix,
-            $cfg );
+            = determine_user_config_filename_from( $username, $suffix, $cfg );
         my $user_cfg
             = MVHub::Utils::ConfigSimple::create_config_from($cfg_filename);
 
@@ -625,7 +623,7 @@
     foreach my $site_code (@SITE_CODES) {
 
         my $cfg_filename
-            = _determine_user_config_filename_from( $username, $site_code,
+            = determine_user_config_filename_from( $username, $site_code,
             $cfg );
         my $user_cfg = new Config::Simple( syntax => 'ini' );
         if ( !-e $cfg_filename ) {

=== modified file 'lib-mvhub/t/AgencyAccount/new.t'
--- lib-mvhub/t/AgencyAccount/new.t	2009-09-15 01:12:17 +0000
+++ lib-mvhub/t/AgencyAccount/new.t	2010-07-14 18:53:41 +0000
@@ -23,7 +23,6 @@
 my @methods = qw/
     cgiapp_postrun
     cgiapp_prerun
-    decode_quick_login_id
     display_agency_home
     display_agency_report
     do_login

=== modified file 'lib-mvhub/t/Notifications/get_expired_records.t'
--- lib-mvhub/t/Notifications/get_expired_records.t	2010-03-31 16:11:24 +0000
+++ lib-mvhub/t/Notifications/get_expired_records.t	2010-07-14 18:53:41 +0000
@@ -14,18 +14,14 @@
 
 use MVHub::Notifications qw/ get_expired_records /;
 use MVHub::Utils::DB qw/ get_dbh /;
-use TestHelper qw/ add_test_data create_sqlite_db /;
 
 BEGIN {
     use FindBin qw($Bin);
     chdir $Bin;
 }
-my $cfg = MVHub::Utils::ConfigSimple::create_config_from(
-    $ENV{MV_TEST_CONFIG_FILE} );
-my $dbh = MVHub::Utils::DB::get_dbh( $ENV{MV_TEST_CONFIG_FILE} );
-
-TestHelper::create_sqlite_db($dbh) or croak "failed to setup test database\n";
-TestHelper::add_test_data($dbh);
+my $cfg
+    = MVHub::Utils::ConfigSimple::create_config_from( $ENV{MV_CONFIG_FILE} );
+my $dbh = MVHub::Utils::DB::get_dbh( $ENV{MV_CONFIG_FILE} );
 
 my $test_message;
 

=== renamed file 'lib-mvhub/t/Utils/Setup/_determine_user_config_filename_from.t' => 'lib-mvhub/t/Utils/Setup/determine_user_config_filename_from.t'
--- lib-mvhub/t/Utils/Setup/_determine_user_config_filename_from.t	2010-06-28 20:13:48 +0000
+++ lib-mvhub/t/Utils/Setup/determine_user_config_filename_from.t	2010-07-14 18:53:41 +0000
@@ -16,19 +16,19 @@
 ###
 $test_message = 'dies when missing 1st parameter';
 ###
-dies_ok { MVHub::Utils::Setup::_determine_user_config_filename_from() }
+dies_ok { MVHub::Utils::Setup::determine_user_config_filename_from() }
 $test_message;
 
 ###
 $test_message = 'dies when missing 2nd parameter';
 ###
-dies_ok { MVHub::Utils::Setup::_determine_user_config_filename_from(1) }
+dies_ok { MVHub::Utils::Setup::determine_user_config_filename_from(1) }
 $test_message;
 
 ###
 $test_message = 'dies when missing 3rd parameter';
 ###
-dies_ok { MVHub::Utils::Setup::_determine_user_config_filename_from( 1, 2 ) }
+dies_ok { MVHub::Utils::Setup::determine_user_config_filename_from( 1, 2 ) }
 $test_message;
 
 ###
@@ -36,7 +36,7 @@
 ###
 my $test_cfg = new Config::Simple( $ENV{MV_TEST_CONFIG_FILE} );
 lives_ok {
-    MVHub::Utils::Setup::_determine_user_config_filename_from( 'test', 'nsp',
+    MVHub::Utils::Setup::determine_user_config_filename_from( 'test', 'nsp',
         $test_cfg );
 }
 $test_message;

=== modified file 'lib-mvhub/t/lib/TestData.pm'
--- lib-mvhub/t/lib/TestData.pm	2010-04-01 18:19:48 +0000
+++ lib-mvhub/t/lib/TestData.pm	2010-07-14 18:53:41 +0000
@@ -126,6 +126,7 @@
         'public_email'         => 'joe_public@xxxxxxxxxxx',
         'agency_id'            => '1001',
         'agency_name'          => 'Test Agency 1',
+        'quick_login_passwd'   => '00000000',
     },
     '1002jane_lane@xxxxxxxxxxx' => {
         'contact_first_name' => 'Jane',
@@ -138,6 +139,7 @@
         'public_email'         => 'jane_public@xxxxxxxxxxx',
         'agency_id'            => '1002',
         'agency_name'          => 'Test Agency 2',
+        'quick_login_passwd'   => '11111111',
     },
     '1003jack_black@xxxxxxxxxxx' => {
         'contact_first_name' => 'Jack',
@@ -150,6 +152,7 @@
         'public_email'         => 'jack_public@xxxxxxxxxxx',
         'agency_id'            => '1003',
         'agency_name'          => 'Test Agency 3',
+        'quick_login_passwd'   => '22222222',
     },
     '1004sue_blue@xxxxxxxxxxx' => {
         'contact_first_name' => 'Sue',
@@ -162,6 +165,7 @@
         'public_email'         => 'sue_public@xxxxxxxxxxx',
         'agency_id'            => '1004',
         'agency_name'          => 'Test Agency 4',
+        'quick_login_passwd'   => '33333333',
     },
     '1005bob_cobb@xxxxxxxxxxx' => {
         'contact_first_name'   => 'Bob',
@@ -173,6 +177,7 @@
         'public_email'         => $dev_user,
         'agency_id'            => '1005',
         'agency_name'          => 'Test Agency 5',
+        'quick_login_passwd'   => '44444444',
     },
 };
 

=== modified file 'lib-mvhub/t/lib/TestHelper.pm'
--- lib-mvhub/t/lib/TestHelper.pm	2010-04-05 17:25:40 +0000
+++ lib-mvhub/t/lib/TestHelper.pm	2010-07-14 18:53:41 +0000
@@ -24,6 +24,7 @@
     get_files
     get_files_from
     get_host_to_check
+    get_quick_login_from
     get_test_website_name
     make_test_file
     no_difference
@@ -111,6 +112,16 @@
     return @files;
 }
 
+sub get_quick_login_from {
+    my $agency_id       = shift or die 'missing param: $agency_id';
+    my $config_filename = shift or die 'missing param: $config_filename';
+    my $dbh = MVHub::Utils::DB::get_dbh($config_filename);
+    my $sql = MVHub::Utils::DB::get_sql_select_statement(
+        'AGENCY_X_QUICK_LOGIN_PASSWD');
+    my $result = ( $dbh->selectrow_array( $sql, {}, $agency_id ) )[0];
+    return $result;
+}
+
 # TODO return something like $USER.$SITE.testing123.net
 # unless host eq 'groundhog';
 # handle things like tests being run in staging site


Follow ups