Changeset 17793 for lang/perl

Show
Ignore:
Timestamp:
08/17/08 22:56:26 (5 years ago)
Author:
tokuhirom
Message:

do not use $c.

Location:
lang/perl/mobirc/trunk
Files:
9 modified

Legend:

Unmodified
Added
Removed
  • lang/perl/mobirc/trunk/lib/App/Mobirc/Plugin/Authorizer/BasicAuth.pm

    r13227 r17793  
    44use Carp; 
    55use App::Mobirc::Util; 
     6use App::Mobirc::Validator; 
    67 
    78has username => ( 
     
    1819 
    1920hook authorize => sub { 
    20     my ( $self, $global_context, $c, ) = @_; 
     21    my ( $self, $global_context, $req, ) = validate_hook('authorize', @_); 
    2122 
    2223    DEBUG "Basic Auth..."; 
     
    2425    my $cred = $self->{username} . ':' . $self->{password}; 
    2526 
    26     my $sent_cred = $c->req->headers->authorization_basic; 
     27    my $sent_cred = $req->headers->authorization_basic; 
    2728    if ( defined($sent_cred) && $sent_cred eq $cred ) { 
    2829        return true; 
  • lang/perl/mobirc/trunk/lib/App/Mobirc/Plugin/Authorizer/Cookie.pm

    r13013 r17793  
    2222 
    2323hook authorize => sub { 
    24     my ( $self, $global_context, $c, ) = validate_hook('authorize', @_); 
     24    my ( $self, $global_context, $req, ) = validate_hook('authorize', @_); 
    2525 
    26     my $cookie_str = $c->req->header('Cookie'); 
     26    my $cookie_str = $req->header('Cookie'); 
    2727    unless ($cookie_str) { 
    2828        DEBUG "cookie header is empty"; 
  • lang/perl/mobirc/trunk/lib/App/Mobirc/Plugin/Authorizer/DoCoMoGUID.pm

    r13318 r17793  
    55use App::Mobirc::Util; 
    66use HTML::StickyQuery::DoCoMoGUID; 
     7use App::Mobirc::Validator; 
    78 
    89has docomo_guid => ( 
     
    1314 
    1415hook authorize => sub { 
    15     my ( $self, $global_context, $c, ) = @_; 
     16    my ( $self, $global_context, $req, ) = validate_hook('authorize', @_); 
    1617 
    17     my $subno = $c->req->header('x-dcmguid'); 
     18    my $subno = $req->header('x-dcmguid'); 
    1819    if ( $subno && $subno eq $self->docomo_guid ) { 
    1920        DEBUG "SUCESS AT DocomoGUID"; 
  • lang/perl/mobirc/trunk/lib/App/Mobirc/Plugin/Authorizer/EZSubscriberID.pm

    r13013 r17793  
    44use Carp; 
    55use App::Mobirc::Util; 
     6use App::Mobirc::Validator; 
    67 
    78has 'au_subscriber_id' => ( 
     
    1213 
    1314hook authorize => sub { 
    14     my ( $self, $global_context, $c, ) = @_; 
     15    my ( $self, $global_context, $req, ) = validate_hook('authorize', @_); 
    1516 
    16     my $subno = $c->req->header('x-up-subno'); 
     17    my $subno = $req->header('x-up-subno'); 
    1718    if ( $subno && $subno eq $self->au_subscriber_id ) { 
    1819        DEBUG "SUCESS AT EZSubscriberID"; 
  • lang/perl/mobirc/trunk/lib/App/Mobirc/Plugin/Authorizer/SoftBankID.pm

    r13013 r17793  
    44use Carp; 
    55use App::Mobirc::Util; 
     6use App::Mobirc::Validator; 
    67 
    78has jphone_uid => ( 
     
    1213 
    1314hook authorize => sub { 
    14     my ( $self, $global_context, $c ) = @_; 
     15    my ( $self, $global_context, $req, ) = validate_hook('authorize', @_); 
    1516 
    16     my $uid = $c->req->header('x-jphone-uid'); 
     17    my $uid = $req->header('x-jphone-uid'); 
    1718    if ( $uid && $uid eq $self->jphone_uid ) { 
    1819        return true; 
  • lang/perl/mobirc/trunk/lib/App/Mobirc/Validator.pm

    r17622 r17793  
    1111        { can => 'register' }, 
    1212        { isa => 'App::Mobirc' }, 
    13         { isa => 'HTTP::Engine::Compat::Context' }, 
     13        { isa => 'HTTP::Engine::Request' }, 
    1414    ], 
    1515    response_filter => [ 
  • lang/perl/mobirc/trunk/lib/App/Mobirc/Web/Handler.pm

    r17792 r17793  
    2929    context->run_hook('request_filter', $req); 
    3030 
    31     if (authorize($c)) { 
     31    if (authorize($req)) { 
    3232        process_request($c); 
    3333        context->run_hook('response_filter', $c); 
     
    4444 
    4545sub authorize { 
    46     my $c = shift; 
     46    my $req = shift; 
    4747 
    48     if (context->run_hook_first('authorize', $c)) { 
     48    if (context->run_hook_first('authorize', $req)) { 
    4949        DEBUG "AUTHORIZATION SUCCEEDED"; 
    5050        return 1; # authorization succeeded. 
  • lang/perl/mobirc/trunk/t/Plugins/Authorizer/BasicAuth.t

    r17622 r17793  
    1515$mobirc->load_plugin( {module => 'Authorizer::BasicAuth', config => {username => 'dankogai', password => 'kogaidan'}} ); 
    1616 
    17 ok !$mobirc->run_hook_first('authorize', create_c('dankogai', 'dankogai')); 
    18 ok $mobirc->run_hook_first('authorize', create_c('dankogai', 'kogaidan')); 
     17ok !$mobirc->run_hook_first('authorize', create_req('dankogai', 'dankogai')); 
     18ok $mobirc->run_hook_first('authorize', create_req('dankogai', 'kogaidan')); 
    1919 
    20 sub create_c { 
     20sub create_req { 
    2121    my ($user, $passwd) = @_; 
    2222    my $c = HTTP::Engine::Compat::Context->new; 
    2323    $c->req->header('Authorization' => 'Basic ' . MIME::Base64::encode("$user:$passwd", '')); 
    24     $c; 
     24    $c->req; 
    2525} 
    2626 
  • lang/perl/mobirc/trunk/t/Plugins/Authorizer/DoCoMoGUID-authorizer.t

    r17622 r17793  
    1717$mobirc->load_plugin( {module => 'Authorizer::DoCoMoGUID', config => {docomo_guid => 'foobar.docomo'}} ); 
    1818 
    19 ok $mobirc->run_hook_first('authorize', create_c('foobar.docomo')), 'login succeeded'; 
    20 ok !$mobirc->run_hook_first('authorize', create_c('invalid_login_id')), 'login failed'; 
     19ok $mobirc->run_hook_first('authorize', create_req('foobar.docomo')), 'login succeeded'; 
     20ok !$mobirc->run_hook_first('authorize', create_req('invalid_login_id')), 'login failed'; 
    2121 
    22 sub create_c { 
     22sub create_req { 
    2323    my $guid = shift; 
    2424    my $c = HTTP::Engine::Compat::Context->new; 
    2525    $c->req->header('x-dcmguid' => $guid); 
    26     $c; 
     26    $c->req; 
    2727} 
    2828