1 |
242 |
ahitrov |
<script type="text/javascript"> |
2 |
|
|
<!-- |
3 |
|
|
opener.location.reload(true); |
4 |
|
|
close(); |
5 |
|
|
//--> |
6 |
|
|
</script> |
7 |
|
|
<%doc> |
8 |
|
|
<pre><% Dumper($user_info) %></pre> |
9 |
|
|
</%doc> |
10 |
|
|
<%doc> |
11 |
|
|
|
12 |
|
|
use LWP::UserAgent; |
13 |
|
|
use JSON::XS; |
14 |
|
|
use URI; |
15 |
|
|
use Encode; |
16 |
|
|
use URI; |
17 |
|
|
use URI::QueryParam; |
18 |
|
|
my $JSON = JSON::XS->new->utf8; |
19 |
|
|
|
20 |
|
|
Manual redirect: |
21 |
|
|
use session::AUTH::Mailru; |
22 |
|
|
my $site = $state->development ? 'www' : 'www'; |
23 |
|
|
my $mail_connect = session::AUTH::Mailru->new( |
24 |
|
|
mail_redirect_uri => 'http://'.$site.'/auth/mailru.html', |
25 |
|
|
); |
26 |
|
|
|
27 |
|
|
|
28 |
|
|
</%doc> |
29 |
|
|
<%once> |
30 |
|
|
|
31 |
|
|
my $site = $state->development ? '' : ''; |
32 |
|
|
use session::AUTH::Mailru; |
33 |
|
|
|
34 |
|
|
</%once> |
35 |
|
|
<%args> |
36 |
|
|
|
37 |
|
|
$code => undef |
38 |
|
|
|
39 |
|
|
</%args> |
40 |
|
|
<%init> |
41 |
|
|
|
42 |
|
|
my $res; |
43 |
|
|
my $info; |
44 |
|
|
|
45 |
|
|
my $mail_connect = session::AUTH::Mailru->new; |
46 |
|
|
my $auth_url = $mail_connect->authorize_url; |
47 |
|
|
if ( $code ) { |
48 |
|
|
my $local_session = $mail_connect->authenticate( code => $code ); |
49 |
|
|
if ( ref $local_session && exists $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 |
|
|
$keeper->{session}->store_value ( |
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 |
|
|
$keeper->{session}->store_value ( |
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> |