|
Revision 13013, 0.8 kB
(checked in by tokuhirom, 5 years ago)
|
|
merge MooseX::Plaggerize branch!
|
| Line | |
|---|
| 1 | package App::Mobirc::Plugin::Authorizer::DoCoMoGUID; |
|---|
| 2 | use strict; |
|---|
| 3 | use MooseX::Plaggerize::Plugin; |
|---|
| 4 | use Carp; |
|---|
| 5 | use App::Mobirc::Util; |
|---|
| 6 | use HTML::StickyQuery::DoCoMoGUID; |
|---|
| 7 | |
|---|
| 8 | has docomo_guid => ( |
|---|
| 9 | is => 'ro', |
|---|
| 10 | isa => 'Str', |
|---|
| 11 | required => 1, |
|---|
| 12 | ); |
|---|
| 13 | |
|---|
| 14 | hook 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 | |
|---|
| 26 | hook '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 | |
|---|
| 34 | 1; |
|---|