File Coverage

blib/lib/Lemonldap/NG/Portal/UserDBFacebook.pm
Criterion Covered Total %
statement 4 6 66.6
branch n/a
condition n/a
subroutine 2 2 100.0
pod n/a
total 6 8 75.0


line stmt bran cond sub pod time code
1             ## @file
2             # UserDB Facebook module
3              
4             ## @class
5             # UserDB Facebook module
6             #
7             # To know attributes that can be asked, take a look at
8             # https://developers.facebook.com/tools/explorer
9             package Lemonldap::NG::Portal::UserDBFacebook;
10              
11 1     1   461 use strict;
  1         1  
  1         30  
12 1     1   594 use Lemonldap::NG::Portal::Simple;
  0            
  0            
13              
14             our $VERSION = '1.4.0';
15              
16             ## @apmethod int userDBInit()
17             # Check if authentication module is Facebook
18             # @return Lemonldap::NG::Portal error code
19             sub userDBInit {
20             my $self = shift;
21              
22             unless ( $self->get_module('auth') =~ /^Facebook/ ) {
23             $self->lmLog(
24             'UserDBFacebook isn\'t useable unless authentication module is set to Facebook',
25             'error'
26             );
27             return PE_ERROR;
28             }
29             PE_OK;
30             }
31              
32             ## @apmethod int getUser()
33             # Does nothing
34             # @return Lemonldap::NG::Portal error code
35             sub getUser {
36             PE_OK;
37             }
38              
39             ## @apmethod int setSessionInfo()
40             # Since the job is done by AuthFacebook, here just check that required
41             # attributes are not null
42             # @return Lemonldap::NG::Portal error code
43             sub setSessionInfo {
44             my $self = shift;
45              
46             my %vars =
47             ( %{ $self->{exportedVars} }, %{ $self->{facebookExportedVars} } );
48             while ( my ( $k, $v ) = each %vars ) {
49             my $attr = $k;
50             my $required = ( $attr =~ s/^!// ) ? 1 : 0;
51             $self->{sessionInfo}->{$attr} = $self->{_facebookDatas}->{$v};
52             if ( $required and not( defined $self->{sessionInfo}->{$attr} ) ) {
53             $self->lmLog(
54             "Required parameter $v is not provided by Facebook server, aborted",
55             'warn'
56             );
57              
58             $self->{mustRedirect} = 0;
59             return PE_MISSINGREQATTR;
60             }
61             }
62             PE_OK;
63             }
64              
65             ## @apmethod int setGroups()
66             # Does nothing
67             # @return Lemonldap::NG::Portal error code
68             sub setGroups {
69             PE_OK;
70             }
71              
72             1;
73