clean
[sgn.git] / lib / SGN / Controller / AJAX / Login.pm
blobf39d8d5ce8a8ddb4ab604ffdc7443bc1b8786b25
2 package SGN::Controller::AJAX::Login;
4 use Moose;
5 use CXGN::Login;
7 BEGIN { extends 'Catalyst::Controller::REST' }
9 __PACKAGE__->config(
10 default => 'application/json',
11 stash_key => 'rest',
12 map => { 'application/json' => 'JSON', 'text/html' => 'JSON' },
16 sub is_logged_in :Path('/user/logged_in') Args(0) {
17 my $self = shift;
18 my $c = shift;
20 if (my $user = $c->user()) {
21 my $user_id = $user->get_object->get_sp_person_id();
22 $c->stash->{rest} = { user_id => $user_id };
23 return;
25 $c->stash->{rest} = { user_id => 0 };
28 sub get_roles :Path('/user/get_roles') Args(0) {
29 my $self = shift;
30 my $c = shift;
32 if (my $user = $c->user()) {
33 my @roles = $user->get_object->get_roles();
34 $c->stash->{rest} = { roles => @roles };
35 return;
37 $c->stash->{rest} = { roles => 0 };
40 sub log_in :Path('/user/login') Args(0) {
41 my $self = shift;
42 my $c = shift;
44 my $login = CXGN::Login->new();
46 # implement
50 sub log_out :Path('/user/logout') Args(0) {
51 my $self = shift;
52 my $c = shift;
54 # implement