Merge branch 'master' into topic/brapi_2.0
[sgn.git] / cgi-bin / solpeople / account-confirm.pl
blobfae367846fa61400d28b8a02cdb8453d8d739458
1 #!/usr/bin/perl -w
2 use strict;
3 use warnings;
5 use CXGN::DB::Connection;
6 use CXGN::Page;
7 use CXGN::People;
8 use CXGN::People::Login;
10 my $page = CXGN::Page->new( "solpeople User Confirmation", "Koni" );
11 my $dbh = CXGN::DB::Connection->new();
13 my ( $username, $confirm_code ) = $page->get_arguments( "username", "confirm" );
14 my $sp = CXGN::People::Login->get_login( $dbh, $username );
16 if ( !$sp ) {
17 confirm_failure($page, "Username \"$username\" was not found.");
20 if ( !$sp->get_confirm_code() ) {
21 confirm_failure($page, "No confirmation is required for user <b>$username</b>. This account has already been confirmed. <p><a href='/user/login?goto_url=%2F'>[Login Page]</a></p>");
24 if ( $sp->get_confirm_code() ne $confirm_code ) {
25 confirm_failure($page, "Confirmation code is not valid!\n");
28 $sp->set_disabled(undef);
29 $sp->set_confirm_code(undef);
30 $sp->set_private_email( $sp->get_pending_email() );
32 $sp->store();
34 $page->header();
36 print <<EOF;
38 <p>Confirmation successful for username <b>$username</b>.</p>
40 <p><a href="/user/login?goto_url=%2F">[Login Page]</a></p>
41 <br />
43 EOF
45 $page->footer();
47 sub confirm_failure {
48 my ($page, $reason) = @_;
50 $page->header();
52 print <<EOF;
54 <p>Sorry, we are unable to process this confirmation request. Please check that your complete confirmation URL has been pasted correctly into your browser.</p>
56 <p><b>Reason:</b> $reason</p>
58 <br />
60 EOF
62 $page->footer();
64 exit 0;