mvhub-dev team mailing list archive
-
mvhub-dev team
-
Mailing list archive
-
Message #00433
[Branch ~mvhub-commit/mvhub/trunk] Rev 441: merged lp:mvhub/trunk
Merge authors:
Priya Ravindran (priya)
Related merge proposals:
https://code.launchpad.net/~priya/mvhub/move_prerun/+merge/29575
proposed by: Priya Ravindran (priya)
review: Approve - Dan MacNeil (omacneil)
------------------------------------------------------------
revno: 441 [merge]
committer: Dan MacNeil <dan@xxxxxxxxxxxx>
branch nick: trunk
timestamp: Fri 2010-07-09 12:17:31 -0400
message:
merged lp:mvhub/trunk
modified:
lib-mvhub/lib/MVHub/AgencyAccount.pm
lib-mvhub/lib/MVHub/CGIAppBase.pm
--
lp:mvhub
https://code.launchpad.net/~mvhub-commit/mvhub/trunk
Your team MVHub Developers is subscribed to branch lp:mvhub.
To unsubscribe from this branch go to https://code.launchpad.net/~mvhub-commit/mvhub/trunk/+edit-subscription
=== modified file 'lib-mvhub/lib/MVHub/AgencyAccount.pm'
--- lib-mvhub/lib/MVHub/AgencyAccount.pm 2010-07-04 23:16:53 +0000
+++ lib-mvhub/lib/MVHub/AgencyAccount.pm 2010-07-09 16:17:31 +0000
@@ -82,6 +82,87 @@
$self->mode_param('rm');
}
+sub cgiapp_prerun {
+ my $self = shift;
+ my $cgi = $self->query();
+ my $requested_mode = $self->get_current_runmode();
+
+ # Modes that require the user to first be logged in:
+ my @LOGIN_ONLY_MODES = qw(display_agency_home remove_agency);
+
+ MVHub::Utils::clean_cgi_params($cgi);
+
+ $self->header_add( -Cache_Control => 'no-store' );
+
+ my $cookie_name = $self->get_config_param('COOKIES.auth_cookie_name');
+ my $tmp_dir = $self->get_config_param('ABSOLUTE_PATH.tmp_dir');
+
+ my $session_id = $cgi->cookie($cookie_name);
+
+ my $cgi_agency_id = $cgi->param('agency_id');
+
+ # TODO put Directory in config file [PATH].session_dir
+ my $session
+ = new CGI::Session( "driver:File", $session_id,
+ { Directory => $tmp_dir } )
+ or croak CGI::Session->erstr();
+
+ if ( !defined $session_id || $session_id ne $session->id() ) {
+
+ if ( grep /$requested_mode/, @LOGIN_ONLY_MODES ) {
+ $self->param(
+ login_error => 'You must log in to access this page.' );
+ $self->prerun_mode('show_login_page');
+ }
+ }
+ else {
+ my $caller_id = $session->param('caller_id');
+ assert( $caller_id,
+ "Session object does not have a caller_id value" );
+ my $agency_id;
+
+ # If the caller is not an admin, their caller_id is their agency_id.
+ # TODO: better error message if a bad agency_id is passed in
+ if ( $caller_id != $MVHub::Common::ADMIN_ID ) {
+
+ $agency_id = $caller_id;
+
+ if ( defined $cgi_agency_id && $cgi_agency_id != $agency_id ) {
+ if ( grep /$requested_mode/, @LOGIN_ONLY_MODES ) {
+ $self->param( login_error =>
+ 'You must log in to access this page.' );
+ $self->prerun_mode('show_login_page');
+ }
+ }
+ }
+ else {
+
+ $agency_id = $cgi->param('agency_id');
+
+ # If we don't get an agency id, it's either a programming error or
+ # possibly the user is currently logged in as admin, goes back
+ # to the home/search page, and then clicks on agency log-in.
+ # We'll optimistically assume the latter, and just redirect the
+ # user to the admin site.
+ if ( !$agency_id ) {
+ $self->redirect( absolute_path => '/html/admin/' );
+ }
+ }
+
+ # If they requested the show_login_page, send them to their
+ # agency home page (if they aren't an admin)
+ if ( $requested_mode eq 'show_login_page'
+ && $caller_id != $MVHub::Common::ADMIN_ID )
+ {
+ $self->prerun_mode('display_agency_home');
+ }
+
+ # They are logged in, set the caller_id and agency_id params
+ $self->param( agency_id => $agency_id );
+ $self->param( caller_id => $caller_id );
+ }
+}
+
sub cgiapp_postrun {
my $self = shift;
my $output_ref = shift;
=== modified file 'lib-mvhub/lib/MVHub/CGIAppBase.pm'
--- lib-mvhub/lib/MVHub/CGIAppBase.pm 2010-06-23 16:08:47 +0000
+++ lib-mvhub/lib/MVHub/CGIAppBase.pm 2010-07-08 16:17:27 +0000
@@ -56,87 +56,6 @@
return;
}
-sub cgiapp_prerun {
- my $self = shift;
- my $cgi = $self->query();
- my $requested_mode = $self->get_current_runmode();
-
- # Modes that require the user to first be logged in:
- my @LOGIN_ONLY_MODES = qw(display_agency_home remove_agency);
-
- MVHub::Utils::clean_cgi_params($cgi);
-
- $self->header_add( -Cache_Control => 'no-store' );
-
- my $cookie_name = $self->get_config_param('COOKIES.auth_cookie_name');
- my $tmp_dir = $self->get_config_param('ABSOLUTE_PATH.tmp_dir');
-
- my $session_id = $cgi->cookie($cookie_name);
-
- my $cgi_agency_id = $cgi->param('agency_id');
-
- # TODO put Directory in config file [PATH].session_dir
- my $session
- = new CGI::Session( "driver:File", $session_id,
- { Directory => $tmp_dir } )
- or croak CGI::Session->erstr();
-
- if ( !defined $session_id || $session_id ne $session->id() ) {
-
- if ( grep /$requested_mode/, @LOGIN_ONLY_MODES ) {
- $self->param(
- login_error => 'You must log in to access this page.' );
- $self->prerun_mode('show_login_page');
- }
- }
- else {
- my $caller_id = $session->param('caller_id');
- assert( $caller_id,
- "Session object does not have a caller_id value" );
- my $agency_id;
-
- # If the caller is not an admin, their caller_id is their agency_id.
- # TODO: better error message if a bad agency_id is passed in
- if ( $caller_id != $MVHub::Common::ADMIN_ID ) {
-
- $agency_id = $caller_id;
-
- if ( defined $cgi_agency_id && $cgi_agency_id != $agency_id ) {
- if ( grep /$requested_mode/, @LOGIN_ONLY_MODES ) {
- $self->param( login_error =>
- 'You must log in to access this page.' );
- $self->prerun_mode('show_login_page');
- }
- }
- }
- else {
-
- $agency_id = $cgi->param('agency_id');
-
- # If we don't get an agency id, it's either a programming error or
- # possibly the user is currently logged in as admin, goes back
- # to the home/search page, and then clicks on agency log-in.
- # We'll optimistically assume the latter, and just redirect the
- # user to the admin site.
- if ( !$agency_id ) {
- $self->redirect( absolute_path => '/html/admin/' );
- }
- }
-
- # If they requested the show_login_page, send them to their
- # agency home page (if they aren't an admin)
- if ( $requested_mode eq 'show_login_page'
- && $caller_id != $MVHub::Common::ADMIN_ID )
- {
- $self->prerun_mode('display_agency_home');
- }
-
- # They are logged in, set the caller_id and agency_id params
- $self->param( agency_id => $agency_id );
- $self->param( caller_id => $caller_id );
- }
-}
-
# end all modules with 1
1;
__END__