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