Line # Revision Author
1 239 ahitrov <script type="text/javascript">
2 <!--
3 240 ahitrov opener.location.reload(true);
4 239 ahitrov close();
5 //-->
6 </script>
7 <%doc>
8
9 Manual redirect:
10
11 use session::AUTH::FaceBook;
12 240 ahitrov my $site = $state->development ? 'www' : 'www';
13 239 ahitrov 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 242 ahitrov my $auth_url = $fb_connect->authorize_url( state => $state );
28 239 ahitrov if ( $code ) {
29 my $local_session = $fb_connect->authenticate( code => $code, state => $state );
30 272 ahitrov if ( ref $local_session eq 'session::Session' && $local_session->id ) {
31 my $profile = $keeper->{users}->get_profile( id => $local_session->id ) if exists $keeper->{users};
32 239 ahitrov 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 272 ahitrov $local_session->set (
37 239 ahitrov name => $profile->name_full,
38 last_name => $profile->name_family,
39 first_name => $profile->name_part,
40 avatar => $session->{avatar},
41 );
42 } else {
43 272 ahitrov $local_session->set (
44 239 ahitrov 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>