Merge pull request #5290 from solgenomics/topic/fix_upload_pehno
[sgn.git] / lib / SGN / Authentication / Store.pm
bloba0e9778d34cdca15ee7adac7c6399054ac5b599e
2 =head1 NAME
4 SGN::Authentication::Store - a Catalyst compatible store class
6 =head1 DESCRIPTION
8 Implemented according to Catalyst::Plugin::Authentication::Internals
10 =head1 AUTHOR
12 Lukas Mueller <lam87@cornell.edu>
14 =cut
16 use strict;
17 use warnings;
19 package SGN::Authentication::Store;
21 use SGN::Authentication::User;
22 use CXGN::People::Person;
24 sub new {
25 my ( $class, $conf, $c, $realm ) = @_;
27 my $self = bless {}, $class;
29 return $self;
33 sub find_user {
34 my ( $self, $authinfo, $c ) = @_;
36 $c->log->debug("find_user: $authinfo->{username}") if $c->debug;
37 my $sp_person_id = CXGN::People::Person->get_person_by_username( $c->dbc->dbh, $authinfo->{username});
39 my $user;
40 my $sp_person = CXGN::People::Person->new( $c->dbc->dbh, $sp_person_id);
41 if (ref($sp_person) eq 'CXGN::People::Person') {
42 $c->log->debug("Obtained sp_person ".$sp_person->get_sp_person_id()) if $c->debug;
43 my $user = SGN::Authentication::User->new();
45 $c->log->debug("USER ".$sp_person->get_username()." FOUND!") if $c->debug;
46 $user->set_object($sp_person);
47 return $user;
49 else {
50 $c->log->debug("USER $authinfo->{username} NOT FOUND!") if $c->debug;
53 return undef;