4 use CXGN
::DB
::Connection
;
9 my $page = CXGN
::Page
->new( "Login", "john" );
10 my $dbh = CXGN
::DB
::Connection
->new();
11 my $context = SGN
::Context
->new;
12 my $login_controller = CXGN
::Login
->new($dbh);
14 if ( $context->get_conf('is_mirror') ) {
16 "Sorry, but you cannot log in to this site.",
17 "This site is a mirror of <a href=\"http://sgn.cornell.edu\">sgn.cornell.edu</a>. To log in to SGN, go to <a href=\"http://sgn.cornell.edu/solpeople/login.pl\">SGN's login page</a>."
21 if ( !$login_controller->login_allowed() ) {
23 "Sorry, but logins are disabled while our server undergoes maintenance.",
24 "Logins should be available again within 24 hours. Should this condition persist, please contact <a href=\"mailto:sgn-feedback\@sgn.cornell.edu\">sgn-feedback\@sgn.cornell.edu</a>."
28 my ( $username, $password, $goto_url, $logout ) =
29 $page->get_arguments( "username", "pd", "goto_url", "logout" );
31 my $message = "Already have an account? Please log in using the form below.";
33 my $referer = $ENV{HTTP_REFERER
} || '';
34 if ( $referer =~ m
|http
://[^/]+/index
.pl
| ) {
36 # if they were on the front page, send them to "My SGN"
37 $goto_url ||= "/solpeople/top-level.pl";
39 elsif ( $referer =~ m
|account
-confirm
.pl
| ) {
41 # if they just confirmed their account, send them to "My SGN"
42 $goto_url = "/solpeople/top-level.pl";
46 # if they were anywhere else, send them to the referring page
47 $goto_url ||= $referer;
51 if ( $logout && $logout eq "yes" ) #if we are in the process of logging out
53 $login_controller->logout_user();
55 'You have successfully logged out. Thanks for using SGN.');
59 if ( $username && $password ) #else if we are in the process of logging in
61 my $login_info = $login_controller->login_user( $username, $password );
63 #print STDERR "loggin in: $username\n";
64 my $person_id = $login_info->{person_id
};
66 #print STDERR "sp_person_id: $person_id\n";
67 my $account_disabled = $login_info->{account_disabled
};
68 my $logins_disabled = $login_info->{logins_disabled
};
69 my $incorrect_password = $login_info->{incorrect_password
};
70 my $duplicate_cookie = $login_info->{duplicate_cookie_string
};
71 if ($logins_disabled) #if the whole system is disabled, print a message
73 $page->message_page("Sorry, but this login system is disabled.");
75 elsif ($account_disabled) #if their account is disabled, print a message
78 "Account for user $username is disabled for reason '$account_disabled'.",
79 "If your account has not been confirmed, check your email for a confirmation from SGN."
82 elsif ($incorrect_password) #if their password is wrong, print a message
84 $page->message_page( "Incorrect username or password.",
85 "<a href=\"send-password.pl\">[Lost password]</a>" );
87 elsif ($duplicate_cookie) #if we couldn't generate a unique cookie string
90 "Sorry but the login system failed.",
92 "failed to generate new cookie string",
93 "Our random login cookie generator generated a duplicate value!"
96 elsif ($person_id) #if their username and password matched
99 ) #if they came from trying to work somewhere else, send them back
102 #if we logged in from having just logged out,
103 #make sure we don't get sent back to the logout page:
104 if ( $goto_url =~ /login\.pl/ ) {
105 $goto_url = "/solpeople/top-level.pl";
108 $page->client_redirect($goto_url);
110 else #else they are just getting started, so send them to the menu page
112 $page->client_redirect("top-level.pl");
116 else #else we not trying to log in yet
118 if ( $login_controller->has_session()
119 ) #if there's no good reason for them to be here, send them to the menu page
121 $page->client_redirect("top-level.pl");
126 $page->header( 'Sol Genomics Network', 'Login' );
128 <div align="center">$message</div>
129 <div align="center">Your browser must accept cookies for this interface to work correctly.</div>
131 <form name="login" method="post" action="/solpeople/login.pl">
132 <table style="padding: 2em" summary="" cellpadding="2" cellspacing="0" border="0" align="center">
133 <tr><td>Username</td><td><input id="unamefield" type="text" name="username" size="30" value="" /></td></tr>
134 <tr><td colspan="2"></td></tr>
135 <tr><td>Password</td><td><input type="password" name="pd" size="30" value="" /></td></tr>
136 <tr><td colspan="2" align="center"><br /><input type="submit" name="login" value="Login" /></td></tr>
138 <input type="hidden" name="goto_url" value="$goto_url" />
140 <div align="center">New user? <a href="/solpeople/new-account.pl">Sign up for an account</a>.<br />
141 Forgot your password? <a href="/solpeople/send-password.pl">Get it here</a>.</div>
142 <script language="JavaScript" type="text/javascript">
144 document.getElementById("unamefield").focus(1);