File Coverage

blib/lib/Net/OSCAR/ServerCallbacks/23/signon.pm
Criterion Covered Total %
statement 13 13 100.0
branch n/a
condition n/a
subroutine 5 5 100.0
pod n/a
total 18 18 100.0


line stmt bran cond sub pod time code
1             package Net::OSCAR::ServerCallbacks;
2             BEGIN {
3 1     1   25 $Net::OSCAR::ServerCallbacks::VERSION = '1.928';
4             }
5 1     1   6 use strict;
  1         3  
  1         60  
6 1     1   6 use warnings;
  1         2  
  1         26  
7 1     1   8 use Net::OSCAR::Constants;
  1         2  
  1         186  
8 1     1   5 use vars qw($SESSIONS $SCREENNAMES %COOKIES $screenname $connection $snac $conntype $family $subtype $data $reqid $reqdata $session $protobit %data);
  1         2  
  1         550  
9             sub {
10              
11             my $hash;
12             ($screenname, $hash) = ($data{screenname}, $data{auth_response});
13              
14             if(!$SCREENNAMES->{$screenname}) {
15             $connection->proto_send(protobit => "authorization_response", protodata => {error => 1});
16             }
17              
18             my @valid_hashes = map {
19             [$_, encode_password($session, exists($data{pass_is_hashed}) ? md5($SCREENNAMES->{$screenname}->{pw}) : $SCREENNAMES->{$screenname}->{pw}, $_)];
20             } keys %{$SESSIONS->{$screenname}->{keys}};
21              
22             my $valid = 0;
23             foreach (@valid_hashes) {
24             next unless $_->[1] eq $hash;
25             $valid = 1;
26             delete $SCREENNAMES->{$screenname}->{keys}->{$_->[0]};
27             last;
28             }
29              
30             if($valid) {
31             my $key = randchars(256);
32             $connection->proto_send(protobit => "authorization_response", protodata => {
33             screenname => $SCREENNAMES->{$screenname}->{sn},
34             email => $SCREENNAMES->{$screenname}->{email},
35             auth_cookie => $key,
36             server_ip => "127.0.0.1"
37             });
38             $session->delconn($connection);
39              
40             $COOKIES{$key} = {sn => $screenname, conntype => CONNTYPE_BOS};
41             } else {
42             $connection->proto_send(protobit => "authorization_response", protodata => {error => 5});
43             $session->delconn($connection);
44             }
45              
46             };
47