X-Git-Url: http://mj.ucw.cz/gitweb/?a=blobdiff_plain;f=PciIds%2FHtml%2FUsers.pm;h=7783f0c04ab2e988a4893356c9a8c844975b22a1;hb=70ff29444c4fef1c4422398aafa71d02cd8dd5f9;hp=317702fcc2aedc38c710690f93f5ec72d7cffc61;hpb=6173b0f3acbdd6691a729d75e9d2ebfa664c1473;p=pciids.git diff --git a/PciIds/Html/Users.pm b/PciIds/Html/Users.pm index 317702f..7783f0c 100644 --- a/PciIds/Html/Users.pm +++ b/PciIds/Html/Users.pm @@ -16,18 +16,13 @@ use base 'Exporter'; our @EXPORT = qw(&checkLogin ¬LoggedComplaint); -sub genLocMenu( $$$ ) { - my( $req, $args, $actions ) = @_; - my $addr = PciIds::Address::new( $req->uri() ); - genCustomMenu( $req, $addr, $args, $actions ); - genPath( $req, $addr, 1 ); -} - sub genRegisterForm( $$$$ ) { my( $req, $args, $error, $values ) = @_; genHtmlHead( $req, 'Register a new user', undef ); + print "
\n"; print '

Register a new user

'; - genLocMenu( $req, $args, [ [ 'Log in', 'login' ] ] ); + genLocMenu( $req, $args, [ [ 'Log in', 'login' ], [ 'Help', 'help', 'account' ] ] ); + print "
\n"; print '
'.$error.'
' if( defined $error ); print '
'; @@ -69,8 +64,10 @@ sub registerSubmit( $$$ ) {#A registration form has been submited "\nThank you\n". "\n(This is an autogenerated email, do not respond to it)" ); genHtmlHead( $req, 'Registration email sent', undef ); - print "

Register email sent

\n"; - genLocMenu( $req, $args, [ [ 'Log in', 'login' ] ] ); + print "
\n"; + print "

Registration email sent

\n"; + genLocMenu( $req, $args, [ [ 'Log in', 'login' ], [ 'Help', 'help', 'account' ] ] ); + print "
\n"; print '

An email containing further information has been sent to you. Please follow these instruction to finish the registration process.'; @@ -81,8 +78,10 @@ sub registerSubmit( $$$ ) {#A registration form has been submited sub genConfirmForm( $$$$ ) { my( $req, $args, $error, $values ) = @_; genHtmlHead( $req, 'Confirm registration', undef ); + print "

\n"; print '

Confirm registration

'; - genLocMenu( $req, $args, [ [ 'Register', 'register' ] ] ); + genLocMenu( $req, $args, [ [ 'Register', 'register' ], [ 'Help', 'help', 'account' ] ] ); + print "
\n"; print '
'.$error.'
' if( defined $error ); print '

Email address: '.encode( $values->{'email'} ); print ''; @@ -100,8 +99,10 @@ sub genConfirmForm( $$$$ ) { sub usedAddress( $$ ) { my( $req, $args ) = @_; genHtmlHead( $req, 'Used address', undef ); + print "

\n"; print "

Used address

\n"; - genLocMenu( $req, $args, [ [ 'Log in', 'login' ], [ 'Reset password', 'respass' ], [ 'Register', 'register' ] ] ); + genLocMenu( $req, $args, [ [ 'Log in', 'login' ], [ 'Reset password', 'respass' ], [ 'Register', 'register' ], [ 'Help', 'help', 'account' ] ] ); + print "
\n"; print '

An account for this address is already registered. @@ -169,8 +170,10 @@ sub confirmSubmit( $$$ ) { return OK; } genHtmlHead( $req, 'Registered', undef ); + print "

\n"; print "

Registered

\n"; - genLocMenu( $req, $args, [ [ 'Log in', 'login' ] ] ); + genLocMenu( $req, $args, [ [ 'Log in', 'login' ], [ 'Help', 'help', 'account' ] ] ); + print "
\n"; print '

You have registered successfully.'; genHtmlTail(); @@ -181,8 +184,10 @@ sub genLoginForm( $$$$ ) { my( $req, $args, $error, $values ) = @_; $req->headers_out->add( 'Set-Cookie' => new CGI::Cookie( -name => 'cookie-test', -value => 1 ) ); genHtmlHead( $req, 'Login', undef ); + print "

\n"; print '

Login

'; - genLocMenu( $req, $args, [ [ 'Register', 'register' ], [ 'Reset password', 'respass' ] ] ); + genLocMenu( $req, $args, [ [ 'Register', 'register' ], [ 'Reset password', 'respass' ], [ 'Help', 'help', 'account' ] ] ); + print "
\n"; print '

'.$error.'

' if( defined $error ); print '
'; 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 '

'.encode( $last ).'

' 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 ' @@ -363,8 +368,10 @@ sub resetPasswdConfirmFormSubmit( $$$ ) { if( defined( $myHash ) && ( $myHash eq $hash ) ) { changePasswd( $tables, $id, $data->{'password'}, $email ); 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 "

Your password was successfuly changed.\n"; genHtmlTail(); return OK; @@ -380,8 +387,10 @@ sub genProfileForm( $$$$$$ ) { delete $data->{'current_password'}; delete $data->{'confirm_password'}; delete $data->{'password'}; + print "

\n"; print "

User profile

\n"; - genLocMenu( $req, $args, [ logItem( $auth ), [ 'Notifications', 'notifications' ] ] ); + genLocMenu( $req, $args, [ logItem( $auth ), [ 'Notifications', 'notifications' ], [ 'Help', 'help', 'profile' ] ] ); + print "
\n"; print '

'.$error.'

' if defined $error; print "

$info

\n" if defined $info; print '
';