1 package CXGN
::BrAPI
::v1
::Authentication
;
5 use CXGN
::BrAPI
::Pagination
;
7 has
'bcs_schema' => ( isa
=> 'Bio::Chado::Schema',
12 has
'status' => ( isa
=> 'ArrayRef[Maybe[HashRef]]',
19 my $grant_type = shift;
22 my $client_id = shift;
23 my $status = $self->status;
26 push @
$status, { 'warning' => 'Parameter client_id not supported. Please use a username and password.' };
29 my $login_controller = CXGN
::Login
->new($self->bcs_schema->storage->dbh);
36 if ( $login_controller->login_allowed() ) {
37 if ($grant_type eq 'password' || !$grant_type) {
38 my $login_info = $login_controller->login_user( $username, $password );
39 if ($login_info->{account_disabled
}) {
40 push @
$status, { 'error' => 'Account Disabled' };
42 if ($login_info->{incorrect_password
}) {
43 push @
$status, { 'error' => 'Incorrect Password' };
45 if ($login_info->{duplicate_cookie_string
}) {
46 push @
$status, { 'error' => 'Duplicate Cookie String' };
48 if ($login_info->{logins_disabled
}) {
49 push @
$status, { 'error' => 'Logins Disabled' };
51 if ($login_info->{person_id
}) {
52 push @
$status, { 'success' => 'Login Successfull' };
53 $cookie = $login_info->{cookie_string
};
54 $first_name = $login_info->{first_name
};
55 $last_name = $login_info->{last_name
};
58 push @
$status, { 'error' => 'Grant Type Not Supported. Valid grant type: password' };
61 push @
$status, { 'error' => 'Login Not Allowed At This Time.' };
63 my $pagination = CXGN
::BrAPI
::Pagination
->pagination_response(0,1,0);
66 'pagination' => $pagination,
67 'result' => { 'first_name' => $first_name, 'last_name' => $last_name, 'cookie' =>$cookie },
75 my $login_controller = CXGN
::Login
->new($self->bcs_schema->storage->dbh);
76 my $status = $self->status;
77 $login_controller->logout_user();
78 push @
$status, { 'success' => 'User Logged Out'};
79 my $pagination = CXGN
::BrAPI
::Pagination
->pagination_response(0,1,0);
82 'pagination' => $pagination,