-
Notifications
You must be signed in to change notification settings - Fork 194
/
Copy pathUser.pm
48 lines (36 loc) · 915 Bytes
/
User.pm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
package MetaCPAN::Server::User;
use strict;
use warnings;
use Moose;
extends 'Catalyst::Authentication::User';
has obj => (
is => 'ro',
isa => 'MetaCPAN::Model::User::Account',
writer => '_set_obj',
);
sub get_object { shift->obj }
sub store {'Catalyst::Authentication::Plugin::Store::Proxy'}
sub for_session {
shift->obj->id;
}
sub from_session {
my ( $self, $c, $id ) = @_;
my $user = $c->model('ESModel')->doc('account')->get($id);
$self->_set_obj($user) if ($user);
return $user ? $self : undef;
}
sub find_user {
my ( $self, $auth ) = @_;
$self->_set_obj( $auth->{user} );
return $self;
}
sub supports {
my ( $self, @feature ) = @_;
return 1 if ( grep { $_ eq 'session' } @feature );
}
sub data {
my $self = shift;
return $self->obj->meta->get_data( $self->obj );
}
__PACKAGE__->meta->make_immutable( inline_constructor => 0 );
1;