Merge pull request #5280 from solgenomics/5714_phenotype_genotype_data_check
[sgn.git] / lib / SGN / Authentication / User.pm
blob2b1446273e4d7beb51176dc868bfa8b1f920bf57
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 my $c = shift;
35 return $self->{user};
38 sub set_object {
39 my $self = shift;
40 $self->{user} = shift;
43 sub roles {
44 my $self = shift;
45 return $self->{user}->get_roles();
48 sub check_roles {
49 my $self = shift;
50 my @roles = @_;
51 my %has_roles = ();
52 map { $has_roles{$_} = 1; } $self->roles();
54 foreach my $r (@roles) {
55 if (!exists($has_roles{$r})) {
56 return 0;
59 return 1;