📄 loginform.pm
字号:
# $Id: LoginForm.pm,v 1.10 2005/06/29 18:29:55 martin Exp $## Copyright 2005 Nature Publishing Group# This program is free software; you can redistribute it and/or# modify it under the terms of the GNU General Public License# as published by the Free Software Foundation; either version 2# of the License, or (at your option) any later version.## The Bibliotech::Component::LoginForm class provides a login form.package Bibliotech::Component::LoginForm;use strict;use base 'Bibliotech::Component';use Bibliotech::AuthCookie;sub last_updated_basis { ('LOGIN');}sub set_cookie { my ($self, $user, $bibliotech) = @_; my $cookie = Bibliotech::AuthCookie->login_cookie($user, $bibliotech); $bibliotech->request->err_headers_out->add('Set-Cookie' => $cookie);}sub html_content { my ($self, $class, $verbose, $main) = @_; my $cgi = $self->bibliotech->cgi; my $validationmsg; if ($cgi->param('button') eq 'Login') { my $user; eval { my $username = $cgi->param('username'); my $password = $cgi->param('password'); $user = $self->bibliotech->allow_login($username, $password); }; if ($@) { ($validationmsg = $@) =~ s|\n.*$||; $cgi->Delete('password'); # do not redisplay on form } else { $self->set_cookie($user, $self->bibliotech); my $username = $user->username; undef $user; # Class::DBI throws an exception as well if we die with an open table if (my $redirect_uri = $cgi->param('dest') || Bibliotech::AuthCookie->get_login_redirect_cookie($self->bibliotech->request)) { my $cookie = Bibliotech::AuthCookie->login_redirect_cookie('', $self->bibliotech); $self->bibliotech->request->err_headers_out->add('Set-Cookie' => $cookie); $redirect_uri =~ s/_AMP_/&/g; die "Location: $redirect_uri\n"; } die 'Location: '.$self->bibliotech->location."user/$username\n"; } } my $formaction = $self->bibliotech->location.'login'; $formaction .= 'popup' if $self->bibliotech->command->page =~ /popup/; my $o = $cgi->h1('Login'); $o .= $cgi->p("If you don't have an account yet, please ".$cgi->a({-class => 'nav', href => $self->bibliotech->location.'register'}, 'register').". The registration process only takes a minute or so."); $o .= $cgi->br; $o .= $cgi->start_form(-method => 'POST', -action => $formaction, -name => 'login'); $o .= $cgi->hidden('dest'); $o .= $cgi->div({class => 'errormsg'}, $validationmsg) if $validationmsg; $o .= $cgi->span({-class => 'label'}, 'User:'); $o .= $cgi->br; $o .= $cgi->input({-type => 'text', -name => 'username', -class => 'field'}); $o .= $cgi->br; $o .= $cgi->span({-class => 'label'}, 'Password:'); $o .= $cgi->br; $o .= $cgi->input({-type => 'password', -name => 'password', -class => 'field'}); $o .= $cgi->br; $o .= $cgi->input({-type => 'submit', -value => 'Login', -name => 'button', -class => 'button'}); $o .= $cgi->end_form; my $javascript_first_empty = $self->firstempty($cgi, 'login', qw/username password/); return new Bibliotech::Page::HTML_Content({html_parts => {main => $o}, javascript_onload => ($main ? $javascript_first_empty : undef)});}1;__END__
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -