minor fixes
[sgn.git] / lib / SGN / Authentication / User.pm
blob2e477bd542e6e3dd051bb71e71f36905140a77c6
1 =head1 NAME
3 SGN::Authentication::User - a Catalyst compatible user class
5 =head1 DESCRIPTION
7 Implemented according to Catalyst::Plugin::Authentication::Internals
9 =head1 AUTHOR
11 Lukas Mueller <lam87@cornell.edu>
13 =cut
15 use strict;
16 use warnings;
18 package SGN::Authentication::User;
20 use base "Catalyst::Authentication::User";
22 sub id {
23 my $self = shift;
24 return $self->{user}->get_username();
27 sub supported_features {
28 my $self = shift;
29 return { roles =>1, self_check=>1};
32 sub get_object {
33 my $self = shift;
34 return $self->{user};
37 sub set_object {
38 my $self = shift;
39 $self->{user} = shift;
42 sub roles {
43 my $self = shift;
44 return $self->{user}->get_roles();
47 sub check_roles {
48 my $self = shift;
49 my @roles = @_;
50 my %has_roles = ();
51 map { $has_roles{$_} = 1; } $self->roles();
53 foreach my $r (@roles) {
54 if (!exists($has_roles{$r})) {
55 return 0;
58 return 1;