line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Net::Google::Code::Role::Authentication; |
2
|
11
|
|
|
11
|
|
8454
|
use Any::Moose 'Role'; |
|
11
|
|
|
|
|
17
|
|
|
11
|
|
|
|
|
89
|
|
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
with 'Net::Google::Code::Role::Fetchable'; |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
has 'email' => ( |
7
|
|
|
|
|
|
|
isa => 'Str', |
8
|
|
|
|
|
|
|
is => 'rw', |
9
|
|
|
|
|
|
|
); |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
has 'password' => ( |
12
|
|
|
|
|
|
|
isa => 'Str', |
13
|
|
|
|
|
|
|
is => 'rw', |
14
|
|
|
|
|
|
|
); |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub sign_in { |
17
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
18
|
0
|
0
|
|
|
|
|
return 1 if $self->signed_in; |
19
|
0
|
0
|
|
|
|
|
die "need password" unless $self->password; |
20
|
|
|
|
|
|
|
|
21
|
0
|
|
|
|
|
|
$self->mech->get('https://www.google.com/accounts/Login'); |
22
|
|
|
|
|
|
|
|
23
|
0
|
|
|
|
|
|
$self->mech->submit_form( |
24
|
|
|
|
|
|
|
with_fields => { |
25
|
|
|
|
|
|
|
Email => $self->email, |
26
|
|
|
|
|
|
|
Passwd => $self->password, |
27
|
|
|
|
|
|
|
}, |
28
|
|
|
|
|
|
|
); |
29
|
|
|
|
|
|
|
|
30
|
0
|
0
|
|
|
|
|
die 'sign in failed to google code' |
31
|
|
|
|
|
|
|
unless $self->signed_in; |
32
|
|
|
|
|
|
|
|
33
|
0
|
|
|
|
|
|
return 1; |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub sign_out { |
37
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
38
|
0
|
|
|
|
|
|
$self->mech->get('https://www.google.com/accounts/Logout'); |
39
|
|
|
|
|
|
|
|
40
|
0
|
0
|
|
|
|
|
die 'sign out failed to google code' |
41
|
|
|
|
|
|
|
unless $self->signed_in; |
42
|
|
|
|
|
|
|
|
43
|
0
|
|
|
|
|
|
return 1; |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
sub signed_in { |
47
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
48
|
|
|
|
|
|
|
|
49
|
0
|
|
|
|
|
|
my $html = $self->mech->content; |
50
|
0
|
0
|
|
|
|
|
return unless $html; |
51
|
|
|
|
|
|
|
# remove lines of head, style and script |
52
|
0
|
|
|
|
|
|
$html =~ s!.*?!!sg; |
53
|
0
|
|
|
|
|
|
$html =~ s!!!sg; |
54
|
0
|
|
|
|
|
|
$html =~ s!!!sg; |
55
|
|
|
|
|
|
|
|
56
|
0
|
|
|
|
|
|
my @lines = split /\n/, $html; |
57
|
0
|
|
|
|
|
|
my $signed_in; |
58
|
0
|
|
|
|
|
|
my $line = 0; |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
# only check the first 30 lines or so in case user input of 'sign out' |
61
|
|
|
|
|
|
|
# exists below |
62
|
0
|
|
|
|
|
|
for ( @lines ) { |
63
|
0
|
0
|
|
|
|
|
$signed_in = 1 if /sign out/i; |
64
|
0
|
|
|
|
|
|
$line++; |
65
|
0
|
0
|
|
|
|
|
last if $line == 30; |
66
|
|
|
|
|
|
|
} |
67
|
0
|
|
|
|
|
|
return $signed_in; |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
|
70
|
11
|
|
|
11
|
|
9874
|
no Any::Moose; |
|
11
|
|
|
|
|
24
|
|
|
11
|
|
|
|
|
70
|
|
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
1; |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
__END__ |