File Coverage

blib/lib/Dancer2/Plugin/Auth/OAuth/Provider/Github.pm
Criterion Covered Total %
statement 17 17 100.0
branch 1 2 50.0
condition n/a
subroutine 5 5 100.0
pod 0 2 0.0
total 23 26 88.4


line stmt bran cond sub pod time code
1              
2             use strict;
3 1     1   813 use parent 'Dancer2::Plugin::Auth::OAuth::Provider';
  1         3  
  1         38  
4 1     1   5  
  1         3  
  1         7  
5             use HTTP::Request::Common;
6 1     1   69  
  1         3  
  1         266  
7             urls => {
8             access_token_url => "https://github.com/login/oauth/access_token",
9 3     3 0 55 authorize_url => "https://github.com/login/oauth/authorize",
10             user_info => "https://api.github.com/user",
11             }
12             } }
13              
14             my ($self, $session) = @_;
15              
16             my $session_data = $session->read('oauth');
17 1     1 0 5  
18             my $resp = $self->{ua}->request(
19 1         4 GET $self->provider_settings->{urls}{user_info},
20             'Authorization' => 'token '.$session_data->{github}{access_token}
21             );
22              
23             if( $resp->is_success ) {
24 1         25 my $user = $self->_stringify_json_booleans(
25             JSON::MaybeXS::decode_json( $resp->content )
26 1 50       499 );
27 1         12 $session_data->{github}{user_info} = $user;
28             $session->write('oauth', $session_data);
29             }
30 1         4 }
31 1         4  
32             1;