[vhffs-dev] [1567] Sending appropriate HTTP Status codes when some session issue occurs |
[ Thread Index |
Date Index
| More vhffs.org/vhffs-dev Archives
]
Revision: 1567
Author: beuss
Date: 2010-03-19 07:54:59 +0100 (Fri, 19 Mar 2010)
Log Message:
-----------
Sending appropriate HTTP Status codes when some session issue occurs
Modified Paths:
--------------
branches/vhffs-design/vhffs-api/src/Vhffs/Panel.pm
Modified: branches/vhffs-design/vhffs-api/src/Vhffs/Panel.pm
===================================================================
--- branches/vhffs-design/vhffs-api/src/Vhffs/Panel.pm 2010-03-18 15:29:20 UTC (rev 1566)
+++ branches/vhffs-design/vhffs-api/src/Vhffs/Panel.pm 2010-03-19 06:54:59 UTC (rev 1567)
@@ -267,7 +267,6 @@
return @themes;
}
-
sub list_languages
{
my $vhffs = shift;
@@ -391,9 +390,9 @@
my $vhffs = $panel->{vhffs};
my $cgi = $panel->{cgi};
-# TODO Use new templates
my $sid = $cgi->cookie( CGI::Session::name() );
unless( defined $sid ) {
+ print $cgi->header(-status => '401 Authorization needed');
$cgi->delete_all();
# We cannot use add_error since auth.pl instanciate a
# Vhffs::Panel::Anonymous instance...
@@ -404,6 +403,7 @@
my $session = new CGI::Session( undef, $sid, {Directory=>'/tmp'} );
unless( defined $session ) {
+ $cgi->header(-status => '500 Internal server error');
$cgi->delete_all();
$cgi->param('error', gettext('Cannot create or fetch session file, please check that /tmp is readable and writeable') );
require 'auth.pl';
@@ -413,6 +413,7 @@
my $username = $session->param('username');
my $uid = $session->param('uid');
unless( defined $username && defined $uid && !$session->is_new() ) {
+ print $cgi->header(-status => '401 Authorization needed');
$cgi->delete_all();
$cgi->param('error', gettext('Expired session ! Please login again') );
$session->delete();
@@ -422,6 +423,7 @@
my $user = Vhffs::User::get_by_uid($vhffs, $uid);
unless ( defined $user ) {
+ print $cgi->header(-status => '403 Forbidden');
$cgi->delete_all();
$cgi->param('error', gettext('User does not exist') );
$session->delete();
@@ -430,6 +432,7 @@
}
unless( $user->get_status == Vhffs::Constants::ACTIVATED ) {
+ print $cgi->header(-status => '403 Forbidden');
$cgi->delete_all();
$cgi->param('error', gettext('You\'re are not allowed to browse panel') );
$session->delete();
@@ -897,6 +900,7 @@
my $conf = $self->{vhffs}->get_config;
my $create_vars = {
INCLUDE_PATH => $templatedir,
+ ENCODING => 'utf8',
FILTERS => {
i18n => \&gettext,
mail => sub {