line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Kwiki::Users::Cookie; |
2
|
1
|
|
|
1
|
|
36539
|
use Kwiki::Users -Base; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
our $VERSION = "0.01"; |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
const class_title => 'Kwiki users from Cookie lookup'; |
7
|
|
|
|
|
|
|
const user_class => 'Kwiki::User::Cookie'; |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
sub init { |
10
|
|
|
|
|
|
|
$self->hub->config->add_file('user_cookie.yaml'); |
11
|
|
|
|
|
|
|
} |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
package Kwiki::User::Cookie; |
14
|
|
|
|
|
|
|
use base 'Kwiki::User'; |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
field 'name' => ''; |
17
|
|
|
|
|
|
|
field 'id'; |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub process_cookie { |
20
|
|
|
|
|
|
|
return shift; |
21
|
|
|
|
|
|
|
} |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub fetch_user_name_from_cookie { |
24
|
|
|
|
|
|
|
my $cookie_name = shift; |
25
|
|
|
|
|
|
|
my $cookie_value = CGI::cookie($cookie_name); |
26
|
|
|
|
|
|
|
$cookie_value = $self->process_cookie($cookie_value); |
27
|
|
|
|
|
|
|
return $cookie_value; |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
sub set_user_name { |
31
|
|
|
|
|
|
|
return unless $self->is_in_cgi; |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
my $cookie_name = $self->hub->config->user_cookie_name; |
34
|
|
|
|
|
|
|
$cookie_name ||= $self->hub->config->user_cookie_default_name; |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
my $name = ''; |
37
|
|
|
|
|
|
|
$name = $self->fetch_user_name_from_cookie($cookie_name); |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
$name ||= $self->hub->config->user_default_name; |
40
|
|
|
|
|
|
|
$self->name($name); |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
package Kwiki::Users::Cookie; |
45
|
|
|
|
|
|
|
__DATA__ |