';
genForm( [ [ 'Login name or email:', 'text', 'login', 'maxlength="255"' ],
@@ -216,32 +221,26 @@ sub loginSubmit( $$$ ) {
$logged = $salted eq $passwd;
}
if( $logged ) {
- $req->headers_out->add( 'Set-Cookie' => new CGI::Cookie( -name => 'auth', -value => genAuthToken( $tables, $id, $req, undef, $email ) ) );
- $args->{'action'} = ( defined $args->{'redirectaction'} ) ? $args->{'redirectaction'} : 'list';
- my $prefix = ( !defined( $args->{'action'} ) or ( $args->{'action'} eq '' ) or ( $args->{'action'} eq 'list' ) ) ? 'read' : 'mods';
- my $url = "http://".$req->hostname().setAddrPrefix( $req->uri(), $prefix ).buildExcept( 'redirectaction', $args );
- genHtmlHead( $req, 'Logged in', undef );
- print 'Logged in
';
- genPath( $req, PciIds::Address::new( $req->uri() ), 1 );
- print 'You are logged in.';
- print '
' if( defined( $last ) );
- genHtmlTail();
- return OK;
+ $req->err_headers_out->add( 'Set-Cookie' => new CGI::Cookie( -name => 'auth', -value => genAuthToken( $tables, $id, $req, undef, $email ) ) );
+ $args->{'action'} = ( defined $args->{'redirectaction'} && $args->{'redirectaction'} ne '' ) ? $args->{'redirectaction'} : 'list';
+ my $url = 'http://'.$req->hostname().setAddrPrefix( $req->uri(), $args->{'action'} eq 'list' ? 'read' : 'mods' ).buildExcept( 'redirectaction', $args );
+ return HTTPRedirect( $req, $url );
} else {
return genLoginForm( $req, $args, 'Invalid login credetials', $data );
}
}
sub logout( $$ ) {
- my( $req, $args, $tables, $auth ) = @_;
- $req->headers_out->add( 'Set-Cookie' => new CGI::Cookie( -name => 'auth', -value => '0' ) );
- return PciIds::Html::List::list( $req, $args, $tables, {} );
+ my( $req, $args ) = @_;
+ $req->err_headers_out->add( 'Set-Cookie' => new CGI::Cookie( -name => 'auth', -value => '0' ) );
+ return HTTPRedirect( $req, 'http://'.$req->hostname().setAddrPrefix( $req->uri(), 'read' ).buildExcept( 'action', $args ) );
}
sub checkLogin( $$ ) {
my( $req, $tables ) = @_;
my $cookies = fetch CGI::Cookie;
- my( $authed, $id, $regen, $rights, $error, $name ) = checkAuthToken( $tables, $req, defined( $cookies->{'auth'} ) ? $cookies->{'auth'}->value : undef );
+ my $cookie = $cookies->{'auth'};
+ my( $authed, $id, $regen, $rights, $error, $name ) = checkAuthToken( $tables, $req, defined( $cookie ) ? $cookie->value : undef );
if( $regen ) {
$req->headers_out->add( 'Set-Cookie' => new CGI::Cookie( -name => 'auth', -value => genAuthToken( $tables, $id, $req, $rights, $name ) ) );
}
@@ -259,8 +258,10 @@ sub notLoggedComplaint( $$$ ) {
sub genResetPasswdForm( $$$$ ) {
my( $req, $args, $error, $values ) = @_;
genHtmlHead( $req, 'Reset password', undef );
+ print "\n";
print "
Reset password
\n";
- genLocMenu( $req, $args, [ [ 'Log in', 'login' ], [ 'Register', 'register' ] ] );
+ genLocMenu( $req, $args, [ [ 'Log in', 'login' ], [ 'Register', 'register' ], [ 'Help', 'help', 'account' ] ] );
+ print "
\n";
print "If you forgot your password (or didn't create one yet), you can reset it to a new value here.\n";
print "Provide your email address here and further instructions will be sent to you.\n";
print '
'.$error.'
' if( defined $error );
@@ -296,8 +297,10 @@ sub resetPasswdFormSubmit( $$$ ) {
"\n\nThank you\n".
"\n(This is an autogenerated email, do not respond to it)" );
genHtmlHead( $req, 'Reset password', undef );
+ print "\n";
print "
Reset password
\n";
- genLocMenu( $req, $args, [ [ 'Log in', 'login' ] ] );
+ genLocMenu( $req, $args, [ [ 'Log in', 'login' ], [ 'Help', 'help', 'account' ] ] );
+ print "
\n";
print "An email with information has been sent to your address.\n";
genHtmlTail();
return OK;
@@ -310,8 +313,10 @@ sub resetPasswdFormSubmit( $$$ ) {
sub genResetPasswdConfigForm( $$$$$$ ) {
my( $req, $args, $error, $values, $email, $hash ) = @_;
genHtmlHead( $req, 'Reset password', undef );
+ print "
\n";
print "
Reset password
\n";
- genLocMenu( $req, $args, [ [ 'Log in', 'login' ] ] );
+ genLocMenu( $req, $args, [ [ 'Log in', 'login' ], [ 'Help', 'help', 'account' ] ] );
+ print "
\n";
print ''.$error.'
' if( defined $error );
print "You can enter new password here:\n";
print '