Line # Revision Author
1 243 ahitrov <script type="text/javascript">
2 <!--
3 opener.location.reload(true);
4 close();
5 //-->
6 </script>
7 <%doc>
8
9 Manual redirect:
10
11 use session::AUTH::FaceBook;
12 my $site = $state->development ? 'www' : 'www';
13 my $fb_connect = session::AUTH::FaceBook->new(
14 facebook_redirect_uri => 'http://'.$site.'/oauth/facebook.html',
15 );
16
17 </%doc>
18 <%args>
19
20 $code => undef
21 $state => undef
22
23 </%args>
24 <%init>
25
26 my $fb_connect = session::AUTH::FaceBook->new();
27 my $auth_url = $fb_connect->authorize_url( state => $state );
28 if ( $code ) {
29 my $local_session = $fb_connect->authenticate( code => $code, state => $state );
30 if ( ref $local_session && exists $local_session->{id} ) {
31 my $profile = $keeper->{users}->get_profile( id => $local_session->{id} ) if exists $keeper->{users};
32 if ( ref $profile ) {
33 unless ( exists $local_session->{avatar} ) {
34 my $avatar = $profile->get_image('avatar');
35 $session->{avatar} = ref $avatar && exists $avatar->{filename} ? $avatar->{mini}{'54x54'}{filename} : undef;
36 $keeper->{session}->store_value (
37 name => $profile->name_full,
38 last_name => $profile->name_family,
39 first_name => $profile->name_part,
40 avatar => $session->{avatar},
41 );
42 } else {
43 $keeper->{session}->store_value (
44 name => $profile->name_full,
45 last_name => $profile->name_family,
46 first_name => $profile->name_part,
47 );
48 }
49 }
50 }
51 } elsif ( $auth_url ) {
52 $m->redirect($auth_url->as_string);
53 } else {
54 &abort404 unless $DEBUG;
55 }
56
57 </%init>