[Rt-commit] rt branch, 3.8-trunk, updated. rt-3.8.5-171-gcfe9758
jesse
jesse at bestpractical.com
Tue Sep 29 16:45:22 EDT 2009
The branch, 3.8-trunk has been updated
via cfe9758ece6021697b114b6d27c0e4434fe78649 (commit)
from 0e4f1f6bba30686d04dbc660221c6791a795002c (commit)
Summary of changes:
lib/RT/Interface/Web.pm | 44 ++++++++++++++++++++++++++++++++
share/html/Elements/SetupSessionCookie | 33 +-----------------------
2 files changed, 45 insertions(+), 32 deletions(-)
- Log -----------------------------------------------------------------
commit cfe9758ece6021697b114b6d27c0e4434fe78649
Author: Jesse Vincent <jesse at bestpractical.com>
Date: Wed Sep 30 05:45:11 2009 +0900
Moved the meat of SetupSessionCookie into the libraries
diff --git a/lib/RT/Interface/Web.pm b/lib/RT/Interface/Web.pm
index 8c7959e..d542e0f 100755
--- a/lib/RT/Interface/Web.pm
+++ b/lib/RT/Interface/Web.pm
@@ -357,6 +357,50 @@ sub AttemptPasswordAuthentication {
$m->callback( %$ARGS, CallbackName => 'SuccessfulLogin', CallbackPage => '/autohandler' );
}
+=head2 SetupSessionCookie
+
+Load or setup a session cookie for the current user.
+
+=cut
+
+sub SetupSessionCookie {
+ my $ARGS = shift;
+ use RT::Interface::Web::Session;
+
+ my %cookies = CGI::Cookie->fetch;
+ my $cookiename = "RT_SID_" . RT->Config->Get('rtname');
+ $cookiename .= "." . $ENV{'SERVER_PORT'} if $ENV{'SERVER_PORT'};
+ my $SessionCookie = ( $cookies{$cookiename} ? $cookies{$cookiename}->value : undef );
+
+ tie %HTML::Mason::Commands::session, 'RT::Interface::Web::Session', $SessionCookie;
+ undef $cookies{$cookiename} unless $SessionCookie && $HTML::Mason::Commands::session{'_session_id'} eq $SessionCookie;
+
+ if ( int RT->Config->Get('AutoLogoff') ) {
+ my $now = int( time / 60 );
+ my $last_update = $HTML::Mason::Commands::session{'_session_last_update'} || 0;
+
+ if ( $last_update && ( $now - $last_update - RT->Config->Get('AutoLogoff') ) > 0 ) {
+
+ # clean up sessions, but we should leave the session id
+ # Should be creating a new session here
+ %HTML::Mason::Commands::session = ( _session_id => $HTML::Mason::Commands::session{'_session_id'} );
+ }
+
+ # save session on each request when AutoLogoff is turned on
+ $HTML::Mason::Commands::session{'_session_last_update'} = $now if $now != $last_update;
+ }
+
+ if ( !$cookies{$cookiename} ) {
+ my $cookie = new CGI::Cookie(
+ -name => $cookiename,
+ -value => $HTML::Mason::Commands::session{_session_id},
+ -path => RT->Config->Get('WebPath'),
+ -secure => ( RT->Config->Get('WebSecureCookies') ? 1 : 0 )
+ );
+ $HTML::Mason::Commands::r->headers_out->{'Set-Cookie'} = $cookie->as_string;
+ }
+}
+
=head2 Redirect URL
This routine ells the current user's browser to redirect to URL.
diff --git a/share/html/Elements/SetupSessionCookie b/share/html/Elements/SetupSessionCookie
index 1e7e769..e4208d6 100755
--- a/share/html/Elements/SetupSessionCookie
+++ b/share/html/Elements/SetupSessionCookie
@@ -48,38 +48,7 @@
<%INIT>
return if $m->is_subrequest; # avoid reentrancy, as suggested by masonbook
-use RT::Interface::Web::Session;
-
-my %cookies = CGI::Cookie->fetch;
-my $cookiename = "RT_SID_". RT->Config->Get('rtname');
-$cookiename .= ".". $ENV{'SERVER_PORT'} if $ENV{'SERVER_PORT'};
-$SessionCookie ||= ( $cookies{$cookiename} ? $cookies{$cookiename}->value : undef ),
-
-tie %session, 'RT::Interface::Web::Session', $SessionCookie;
-undef $cookies{$cookiename} unless $SessionCookie && $session{'_session_id'} eq $SessionCookie;
-
-if ( int RT->Config->Get('AutoLogoff') ) {
- my $now = int(time/60);
- my $last_update = $session{'_session_last_update'} || 0;
-
- if ( $last_update && ($now - $last_update - RT->Config->Get('AutoLogoff')) > 0 ) {
- # clean up sessions, but we should leave the session id
- %session = (_session_id => $session{'_session_id'});
- }
-
- # save session on each request when AutoLogoff is turned on
- $session{'_session_last_update'} = $now if $now != $last_update;
-}
-
-if ( !$cookies{$cookiename} ) {
- my $cookie = new CGI::Cookie(
- -name => $cookiename,
- -value => $session{_session_id},
- -path => RT->Config->Get('WebPath'),
- -secure => (RT->Config->Get('WebSecureCookies') ? 1 :0)
- );
- $r->headers_out->{'Set-Cookie'} = $cookie->as_string;
-}
+RT::Interface::Web::SetupSessionCookie();
return ();
</%INIT>
-----------------------------------------------------------------------
More information about the Rt-commit
mailing list