Line # Revision Author
1 844 ahitrov <!DOCTYPE html>
2 <head>
3 <script type="text/javascript">
4 <!--
5 opener.location.reload(true);
6 close();
7 //-->
8 </script>
9 </head>
10 </html>
11 <%doc>
12
13 use LWP::UserAgent;
14 use JSON::XS;
15 use URI;
16 use Encode;
17 use URI;
18 use URI::QueryParam;
19 my $JSON = JSON::XS->new->utf8;
20
21 Manual redirect:
22 use session::AUTH::VKontakte;
23 my $site = $state->development ? 'www' : 'www';
24 my $vk_connect = session::AUTH::VKontakte->new(
25 vk_redirect_uri => 'http://'.$site.'/oauth/vkontakte.html',
26 );
27
28
29 </%doc>
30 <%once>
31
32 my $site = $state->development ? '' : '';
33
34 </%once>
35 <%args>
36
37 $code => undef
38
39 </%args>
40 <%init>
41
42 my $res;
43 my $info;
44
45 my $vk_connect = session::AUTH::VKontakte->new;
46 my $auth_url = $vk_connect->authorize_url;
47 if ( $code ) {
48 my $local_session = $vk_connect->authenticate( code => $code );
49 if ( ref $local_session eq 'session::Session' && $local_session->id ) {
50 my $profile = $keeper->{users}->get_profile( id => $local_session->id ) if exists $keeper->{users};
51 if ( ref $profile ) {
52 unless ( exists $local_session->{avatar} ) {
53 my $avatar = $profile->get_image('avatar');
54 $session->{avatar} = ref $avatar && exists $avatar->{filename} ? $avatar->{mini}{'54x54'}{filename} : undef;
55 $local_session->set (
56 name => $profile->name_full,
57 last_name => $profile->name_family,
58 first_name => $profile->name_part,
59 avatar => $session->{avatar},
60 );
61 } else {
62 $local_session->set (
63 name => $profile->name_full,
64 last_name => $profile->name_family,
65 first_name => $profile->name_part,
66 );
67 }
68 }
69 }
70 } elsif ( $auth_url ) {
71 $m->redirect($auth_url->as_string);
72 } else {
73 &abort404 unless $DEBUG;
74 }
75
76 </%init>