2 package SGN
::Controller
::User
;
6 BEGIN { extends
'Catalyst::Controller' };
8 sub login
:Path
('/user/login') Args
(0) {
12 $c->stash->{goto_url
} = $c->req->param("goto_url");
14 print STDERR
"GOTOURL=".$c->stash->{goto_url
}."\n";
15 $c->stash->{template
} = '/user/login.mas';
18 sub new_user
:Path
('/user/new') Args
(0) {
22 # Redirect to the login page and display the new user form
23 $c->res->redirect('/user/login?goto_url=/&new_user=1');
27 sub update_account
:Path
('/user/update') Args
(0) {
32 $c->res->redirect('/user/login');
36 $c->stash->{logged_in_username
} = $c->user()->get_username();
37 $c->stash->{private_email
} = $c->user()->get_private_email();
39 $c->stash->{template
} = '/user/change_account.mas';
42 sub confirm_user
:Path
('/user/confirm') Args
(0) {
46 my $confirm_code = $c->req->param('confirm_code');
47 my $username = $c->req->param('username');
49 if ($c->config->{disable_account_confirm
}) {
50 $c->stash->{template
} = '/generic_message.mas';
51 $c->stash->{message
} = 'Account confirmation is disabled on this site. Please contact nm529@cornell.edu to confirm your account.';
55 my $sp = CXGN
::People
::Login
->get_login( $c->dbc()->dbh(), $username );
58 confirm_failure
($c, "Username \"$username\" was not found.");
62 if ( !$sp->get_confirm_code() ) {
63 confirm_failure
($c, "No confirmation is required for user <b>$username</b>. This account has already been confirmed. <p><a href='/user/login'>[Login Page]</a></p>");
67 if ( $sp->get_confirm_code() ne $confirm_code ) {
68 confirm_failure
($c, "Confirmation code is not valid!\n");
72 $sp->set_disabled(undef);
73 $sp->set_confirm_code(undef);
74 $sp->set_private_email( $sp->get_pending_email() );
78 $c->stash->{template
} = '/generic_message.mas';
79 $c->stash->{message
} = "Confirmation successful for username <b>$username</b>";
86 $c->stash->{template
} = '/generic_message.mas';
87 $c->stash->{message
} = "Sorry, this confirmation code is invalid. Please check that your complete confirmation URL has been pasted correctly into your browser. ($reason)";
91 sub reset_password_form
:Path
('/user/reset_password_form') Args
(0) {
95 my $token = $c->req->param('reset_password_token');
99 my $person_id = CXGN
::People
::Login
->get_login_by_token($c->dbc->dbh(), $token);
101 $c->stash->{message
} = "The provided password reset link is invalid. Please try again with another link.";
102 $c->stash->{template
} = '/generic_message.mas';
106 my $person = CXGN
::People
::Person
->new($c->dbc->dbh(), $person_id);
107 $c->stash->{token
} = $token;
108 $c->stash->{person_id
} = $person_id;
109 $c->stash->{username
} = $person->get_username();
110 $c->stash->{template
} = '/user/reset_password_form.mas';
113 $c->stash->{message
} = "No token provided. Please try again.";
114 $c->stash->{template
} = '/generic_message.mas';
119 sub quick_create_account
:Path
('/user/admin/quick_create_account') {
124 $c->forward('/user/login');
128 $c->stash->{template
} = '/user/quick_create_account.mas';