root/lang/perl/mobirc/trunk/lib/App/Mobirc/Plugin/Authorizer/DoCoMoGUID.pm @ 13013

Revision 13013, 0.8 kB (checked in by tokuhirom, 5 years ago)

merge MooseX::Plaggerize branch!

Line 
1package App::Mobirc::Plugin::Authorizer::DoCoMoGUID;
2use strict;
3use MooseX::Plaggerize::Plugin;
4use Carp;
5use App::Mobirc::Util;
6use HTML::StickyQuery::DoCoMoGUID;
7
8has docomo_guid => (
9    is       => 'ro',
10    isa      => 'Str',
11    required => 1,
12);
13
14hook authorize => sub {
15    my ( $self, $global_context, $c, ) = @_;
16
17    my $subno = $c->req->header('x-dcmguid');
18    if ( $subno && $subno eq $self->docomo_guid ) {
19        DEBUG "SUCESS AT DocomoGUID";
20        return true;
21    } else {
22        return false;
23    }
24};
25
26hook 'html_filter' => sub {
27    my ($self, $global_context, $c, $content) = @_;
28
29    DEBUG "Filter DoCoMoGUID";
30    return $content unless $c->req->mobile_agent->is_docomo;
31    return ($c, HTML::StickyQuery::DoCoMoGUID->new()->sticky( scalarref => \$content, ));
32};
33
341;
Note: See TracBrowser for help on using the browser.