[Rt-commit] r4130 - rt/branches/3.5-TESTING/html
ruz at bestpractical.com
ruz at bestpractical.com
Mon Nov 21 22:52:06 EST 2005
Author: ruz
Date: Mon Nov 21 22:52:05 2005
New Revision: 4130
Modified:
rt/branches/3.5-TESTING/html/autohandler
Log:
r1331 at cubic-pc (orig r4123): ruz | 2005-11-21 22:30:40 +0300
r1328 at cubic-pc: cubic | 2005-11-21 17:29:03 +0300
* fix time units handling, '1/8' didn't work
* we don't filter args with grep to filter them again in loop
* tidy and code paths cleanup
Modified: rt/branches/3.5-TESTING/html/autohandler
==============================================================================
--- rt/branches/3.5-TESTING/html/autohandler (original)
+++ rt/branches/3.5-TESTING/html/autohandler Mon Nov 21 22:52:05 2005
@@ -57,8 +57,8 @@
local *session unless $m->is_subrequest; # avoid reentrancy, as suggested by masonbook
# Disable AutoFlush using an attribute
-if ($m->request_comp->attr_exists('AutoFlush')) {
- $m->autoflush($m->request_comp->attr('AutoFlush'));
+if ( $m->request_comp->attr_exists('AutoFlush') ) {
+ $m->autoflush( $m->request_comp->attr('AutoFlush') );
}
%ARGS = map {
@@ -75,23 +75,19 @@
# This code canonicalizes time inputs in hours into minutes
-my @TimeUnitFields = grep { /-TimeUnits$/ } keys %ARGS;
-foreach my $field (@TimeUnitFields) {
- next unless ($field =~ /^(.*?)-TimeUnits$/i);
+foreach my $field ( keys %ARGS ) {
+ next unless $field =~ /^(.*)-TimeUnits$/i && $ARGS{ $1 };
my $local = $1;
- $ARGS{$local} =~ s|\b (\d* \s+) (\d+)/(\d+) \b
- |$1 + ($3 == 0 ? 0 : ($2 / $3))
+ $ARGS{$local} =~ s|\b (?: (\d+) \s+ )? (\d+)/(\d+) \b
+ |$1 + $3 ? $2 / $3 : 0
|xe;
- if ($ARGS{$field} =~ /hours/i) {
+ if ($ARGS{$field} && $ARGS{$field} =~ /hours/i) {
$ARGS{$local} *= 60;
}
delete $ARGS{$field};
}
-
-
-
-$m->{'rt_base_time'} = [Time::HiRes::gettimeofday()];
+$m->{'rt_base_time'} = [ Time::HiRes::gettimeofday() ];
$m->comp('/Elements/SetupSessionCookie', %ARGS);
@@ -103,10 +99,9 @@
$r->content_type("text/html; charset=utf-8");
# If it's a noauth file, don't ask for auth.
-if ($m->base_comp->path =~ $RT::WebNoAuthRegex )
-{
- $m->call_next(%ARGS);
- $m->abort();
+if ( $m->base_comp->path =~ $RT::WebNoAuthRegex ) {
+ $m->call_next( %ARGS );
+ $m->abort;
}
# If RT is configured for external auth, let's go through and get REMOTE_USER
@@ -196,25 +191,25 @@
}
delete $session{'CurrentUser'}
- unless $session{'CurrentUser'} and defined $session{'CurrentUser'}->Id;
+ unless $session{'CurrentUser'} and $session{'CurrentUser'}->Id;
# Process per-page authentication callbacks
$m->comp('/Elements/Callback', %ARGS, _CallbackName => 'Auth');
# If the user is logging in, let's authenticate
-if (!$session{'CurrentUser'} && defined ($user) && defined ($pass) ){
+if (!$session{'CurrentUser'} && defined $user && defined $pass ) {
$session{'CurrentUser'} = RT::CurrentUser->new();
- $session{'CurrentUser'}->Load($user);
+ $session{'CurrentUser'}->Load( $user );
- if (!$session{'CurrentUser'}->id() ||
- !$session{'CurrentUser'}->IsPassword($pass))
+ unless ( $session{'CurrentUser'}->id &&
+ $session{'CurrentUser'}->IsPassword( $pass ) )
{
delete $session{'CurrentUser'};
$RT::Logger->error("FAILED LOGIN for $user from $ENV{'REMOTE_ADDR'}");
$m->comp('/Elements/Login', %ARGS,
Error => loc('Your username or password is incorrect'));
- $m->abort();
+ $m->abort;
}
else {
$RT::Logger->info("Successful login for $user from $ENV{'REMOTE_ADDR'}");
More information about the Rt-commit
mailing list