CatalystX/OAuth2/Provider/TraitFor/Controller/OAuth/AuthorizationCode.pm untested

filter: Statementstmt 0.0% 0 / 19 Branchbran 0.0% 0 / 4 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 0.0% 0 / 3 Podpod n/a totaltotal 0.0% 0 / 31 CC 1 SCAR 6.9
CC
1
Cov
0%
BEGIN
2.0
BEGIN
2.0
BEGIN
2.0
CRAP 2.0
1 package CatalystX::OAuth2::Provider::TraitFor::Controller::OAuth::AuthorizationCode;
2  
3 use MooseX::MethodAttributes::Role;
4 use OAuth::Lite::Token;
5 use namespace::autoclean;
6  
7 requires qw/
8 handle_grant_type
9 /;
10  
11 around 'handle_grant_type' => sub {
12 my ( $orig, $self, $ctx, $grant_type ) = @_;
13  
14 if (! $ctx->session->{token}) {
15 my $t = OAuth::Lite::Token->new_random;
16 $ctx->session->{token} = $t->token;
17 }
18  
19 if ( $grant_type && ( $grant_type eq 'authorization_code' ) ) {
20 my %data = ( access_token => $ctx->session->{token},
21 expires_in => 3600, #TODO: Make access_token expires
22 scope => undef, #TODO: Support scope
23 refresh_token => $ctx->session->{token} );
24 $ctx->res->body( JSON::XS->new->pretty(1)->encode( \%data ) );
25 $ctx->detach();
26 }
27  
28 };
29  
30 =pod
31 =cut
32  
33 1;