Skip to content
Browse files

add a function for error reporting

  • Loading branch information...
1 parent c7ccea9 commit 2cc06ca9603b336d1a0bc9f247b64ccbc404eb3a @ruz ruz committed Mar 9, 2009
Showing with 10 additions and 12 deletions.
  1. +10 −12 html/Callbacks/Bitcard/autohandler/Auth
View
22 html/Callbacks/Bitcard/autohandler/Auth
@@ -3,6 +3,13 @@
# so bail quickly
return unless exists $ARGS{bc_id};
+ my $error_cb = sub {
+ my %args = @_;
+ my $qs = $m->comp('/Elements/QueryString', Error => $args{'Error'} );
+ $m->redirect( $RT::WebPath . '/?' . $qs);
+ $m->abort();
+ };
+
# flush the current session if user tries to login using bitcard
%session = (_session_id => $session{'_session_id'});
@@ -16,10 +23,7 @@
# bitcard user verify error. abort abort abort!
unless ( $user ) {
$RT::Logger->warning( "Bitcard verify() returned undef: ". $bc->errstr );
- my $qs = $m->comp('/Elements/QueryString',
- Error => $bc->errstr );
- $m->redirect( $RT::WebPath . '/?' . $qs);
- $m->abort();
+ $error_cb->( Error => $bc->errstr );
}
# upgrade octets returned by Authen::BC into perl strings
@@ -34,10 +38,7 @@
# if the user isn't logged in and we got credentials from Bitcard, load the user
unless ( defined $user->{'email'} && defined $user->{'username'} ) {
$RT::Logger->error("Bitcard server didn't provided email and user name, but signature is correct");
- my $qs = $m->comp('/Elements/QueryString',
- Error => loc("Couldn't login using Bitcard. Contact system administrator") );
- $m->redirect( $RT::WebPath . '/?' . $qs);
- $m->abort();
+ $error_cb->( Error => loc("Couldn't login using Bitcard. Contact system administrator") );
}
# Bitcard has verified that the user has control of this e-mail address,
@@ -76,9 +77,6 @@
}
else {
# we couldn't create the user. abort abort abort!
- my $qs = $m->comp('/Elements/QueryString',
- Error => loc("Cannot create user: [_1]", $msg));
- $m->redirect($RT::WebPath . '/?' . $qs);
- $m->abort();
+ $error_cb->( Error => loc("Cannot create user: [_1]", $msg) );
}
</%INIT>

0 comments on commit 2cc06ca

Please sign in to comment.
Something went wrong with that request. Please try again.