blib/lib/PEF/Front/Oauth/VKontakte.pm untested

filter: Statementstmt 0.0% 0 / 34 Branchbran 0.0% 0 / 2 Conditioncond 0.0% 0 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 0.0% 0 / 14 Podpod 0.0% 0 / 8 totaltotal 0.0% 0 / 61 CC 2 SCAR 9.3
CC
2
Cov
0%
_parse_user_info
6.0
_authorization_server
2.0
_required_redirect_uri
2.0
CRAP 2.5
1 package PEF::Front::Oauth::VKontakte;
2  
3 use strict;
4 use warnings;
5 use base 'PEF::Front::Oauth';
6 use HTTP::Request::Common;
7 use feature 'state';
8 use PEF::Front::Config;
9  
10 sub _authorization_server {
11 'http://oauth.vk.com/authorize';
12 }
13  
14 sub _required_redirect_uri { 1 }
15 sub _required_state { 0 }
16 sub _returns_state { 0 }
17  
18 sub _token_request {
19 my ($self, $code) = @_;
20 my $req = GET 'https://oauth.vk.com/access_token';
21 $req->uri->query_form(
22 client_id => cfg_oauth_client_id($self->{service}),
23 client_secret => cfg_oauth_client_secret($self->{service}),
24 code => $code,
25 redirect_uri => $self->{session}->data->{oauth_redirect_uri}{$self->{service}}
26 );
27 }
28  
29 sub _get_user_info_request {
30 my ($self) = @_;
31 my $req = GET 'https://api.vk.com/method/users.get';
32 $req->uri->query_form(
33 access_token => $self->{session}->data->{oauth_access_token}{$self->{service}},
34 uids => $self->{session}->data->{oauth_info_raw}{$self->{service}}{user_id},
35 fields => 'photo_50,first_name,last_name,nickname,screen_name'
36 );
37 $req;
38 }
39  
40 sub _parse_user_info {
41 my ($self) = @_;
42 my $info = $self->{session}->data->{oauth_info_raw}{$self->{service}};
43 my @avatar = ();
44 @avatar = ({url => $info->{photo_50}}) if $info->{photo_50};
45 return {
46 name => $info->{first_name} . ' ' . $info->{last_name},
47 email => '',
48 login => $info->{screen_name} || '',
49 avatar => \@avatar,
50 };
51 }
52  
53 sub new {
54 my ($class, $self) = @_;
55 bless $self, $class;
56 }
57  
58 1;