[vhffs-dev] [864] merged logout.pl to auth.pl

[ Thread Index | Date Index | More vhffs.org/vhffs-dev Archives ]


Revision: 864
Author:   gradator
Date:     2007-09-04 17:34:02 +0000 (Tue, 04 Sep 2007)

Log Message:
-----------
merged logout.pl to auth.pl

Modified Paths:
--------------
    trunk/vhffs-api/src/Vhffs/Panel/Main.pm
    trunk/vhffs-panel/Makefile.am
    trunk/vhffs-panel/auth.pl
    trunk/vhffs-panel/templates/Makefile.am
    trunk/vhffs-panel/templates/main/auth.tmpl
    trunk/vhffs-panel/templates/menu/main.tmpl
    trunk/vhffs-panel/templates/menu/user.tmpl

Removed Paths:
-------------
    trunk/vhffs-panel/logout.pl
    trunk/vhffs-panel/templates/main/logout.tmpl


Modified: trunk/vhffs-api/src/Vhffs/Panel/Main.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/Panel/Main.pm	2007-09-04 00:12:11 UTC (rev 863)
+++ trunk/vhffs-api/src/Vhffs/Panel/Main.pm	2007-09-04 17:34:02 UTC (rev 864)
@@ -760,6 +760,7 @@
 	$this->{theme} = $theme;
 	$this->{themecookie} = $themecookie;
     $this->{errors} = [];
+    $this->{infos} = [];
     bless($this, $class);
 
 	return $this;
@@ -810,9 +811,14 @@
         $template->param( ERRORS => $tmplerrors->output );
     }
 
+    if(@{$panel->{infos}} > 0) {
+        my $tmplinfos = new HTML::Template( filename => $panel->{templatedir}.'/panel/misc/infos.tmpl' );
+        $tmplinfos->param( INFOS => $panel->{infos} );
+        $template->param( INFOS => $tmplinfos->output );
+    }
 
-	print $template->output;
-	return;
+    print $template->output;
+    return;
 }
 
 =pod

Modified: trunk/vhffs-panel/Makefile.am
===================================================================
--- trunk/vhffs-panel/Makefile.am	2007-09-04 00:12:11 UTC (rev 863)
+++ trunk/vhffs-panel/Makefile.am	2007-09-04 17:34:02 UTC (rev 864)
@@ -9,7 +9,6 @@
 	favicon.ico \
 	getavatar.pl \
 	history.pl \
-	logout.pl \
 	lost.pl \
 	lost_ack.pl \
 	panel.pl \

Modified: trunk/vhffs-panel/auth.pl
===================================================================
--- trunk/vhffs-panel/auth.pl	2007-09-04 00:12:11 UTC (rev 863)
+++ trunk/vhffs-panel/auth.pl	2007-09-04 17:34:02 UTC (rev 864)
@@ -47,13 +47,14 @@
 my $vhffs = $panel->{'vhffs'};
 my $templatedir = $panel->{'templatedir'};
 my $cgi = $panel->{cgi};
-my $submitted = defined($cgi->param('login_submit'));
+my $loginsubmitted = defined( $cgi->param('login_submit') );
+my $logoutsubmitted = defined( $cgi->param('logout') );
 
-if($submitted) {
+if( $loginsubmitted ) {
     # User tried to log in
     # we try to clean the previous session
-    my $oldsid = CGI->cookie('session');
-    if( $oldsid ) {
+    my $oldsid = CGI->cookie( CGI::Session::name() );
+    if( defined $oldsid ) {
         my $oldsession = new CGI::Session(undef, $oldsid, {Directory=>'/tmp'});
         $oldsession->delete();
     }
@@ -64,8 +65,7 @@
     $user = Vhffs::User::get_by_username($vhffs, $username) if(defined $username);
 
     #Incomplete input
-    if( ! defined( $username ) || ! defined ( $password ) || !defined $user 
-            || !$user->check_password( $password )) {
+    unless( defined $username  &&  defined $password  &&  defined $user  &&  $user->check_password( $password ) ) {
         $panel->add_error( gettext('Login failed !') );
     } elsif($user->get_status != Vhffs::Constants::ACTIVATED) {
         $panel->add_error( gettext('User is not active yet') );
@@ -87,6 +87,19 @@
     }
 }
 
-if(!$submitted || $panel->has_errors) {
-    Vhffs::Panel::Commons::display_login($vhffs, $panel);
+if( $logoutsubmitted )  {
+	#clean session
+	my $oldsid = CGI->cookie( CGI::Session::name() );
+	if( defined $oldsid )  {
+		my $oldsession = new CGI::Session(undef, $oldsid, {Directory=>'/tmp'});
+		$oldsession->delete();
+	}
+
+	$panel->add_info( gettext('You left your VHFFS session!') );
+
+	Vhffs::Panel::Commons::display_login($vhffs, $panel);
 }
+
+if( ( ! $loginsubmitted  &&  ! $logoutsubmitted )  ||  $panel->has_errors ) {
+	Vhffs::Panel::Commons::display_login($vhffs, $panel);
+}

Deleted: trunk/vhffs-panel/logout.pl
===================================================================
--- trunk/vhffs-panel/logout.pl	2007-09-04 00:12:11 UTC (rev 863)
+++ trunk/vhffs-panel/logout.pl	2007-09-04 17:34:02 UTC (rev 864)
@@ -1,62 +0,0 @@
-#!%PERL% -w
-# Copyright (c) vhffs project and its contributors
-# All rights reserved.
-#
-# Redistribution and use in source and binary forms, with or without 
-# modification, are permitted provided that the following conditions 
-# are met:
-#
-# 1. Redistributions of source code must retain the above copyright 
-#   notice, this list of conditions and the following disclaimer.
-#2. Redistributions in binary form must reproduce the above copyright
-#   notice, this list of conditions and the following disclaimer in 
-#   the documentation and/or other materials provided with the 
-#   distribution.
-#3. Neither the name of vhffs nor the names of its contributors 
-#   may be used to endorse or promote products derived from this 
-#   software without specific prior written permission.
-#
-#THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
-#"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
-#LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 
-#FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 
-#COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 
-#INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 
-#BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 
-#LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 
-#CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 
-# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 
-# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
-# POSSIBILITY OF SUCH DAMAGE.
-
-
-use POSIX qw(locale_h);
-use HTML::Template;
-use locale;
-use Locale::gettext;
-use CGI;
-use CGI::Session;
-use strict;
-use lib '%VHFFS_LIB_DIR%';
-use Vhffs::Panel::Main;
-
-my $panel = new_light Vhffs::Panel::Main();
-my $vhffs = $panel->{'vhffs'};
-my $templatedir = $panel->{'templatedir'};
-
-#clean session
-my $sid = CGI->cookie(CGI::Session::name());
-if( $sid )
-{
-	my $session = new CGI::Session(undef, $sid, {Directory=>'/tmp'});
-	$session->delete();
-}
-
-
-my $template = new HTML::Template( filename => $templatedir."/panel/main/logout.tmpl" );
-
-$template->param( TITLE => gettext("VHFFS Logout") );
-$template->param( TEXT_LOGOUT => gettext("You left your VHFFS session!") );
-$template->param( TEXT_LOGIN => gettext("Access to panel") );
-
-display_light Vhffs::Panel::Main( $panel , $template );

Modified: trunk/vhffs-panel/templates/Makefile.am
===================================================================
--- trunk/vhffs-panel/templates/Makefile.am	2007-09-04 00:12:11 UTC (rev 863)
+++ trunk/vhffs-panel/templates/Makefile.am	2007-09-04 17:34:02 UTC (rev 864)
@@ -110,7 +110,6 @@
 	menu/context-modo.tmpl \
 	main/login_failed.tmpl \
 	main/login_ok.tmpl \
-	main/logout.tmpl \
 	main/lost_failed.tmpl \
 	main/lost_ok.tmpl \
 	main/lost.tmpl \

Modified: trunk/vhffs-panel/templates/main/auth.tmpl
===================================================================
--- trunk/vhffs-panel/templates/main/auth.tmpl	2007-09-04 00:12:11 UTC (rev 863)
+++ trunk/vhffs-panel/templates/main/auth.tmpl	2007-09-04 17:34:02 UTC (rev 864)
@@ -28,6 +28,7 @@
 			<form action="/auth.pl" method="post">
 			<h2><tmpl_var name="TEXT_PLEASEIDENTIFY"></h2>
                 <tmpl_var name="errors">
+                <tmpl_var name="infos">
 				<p>
 					<label for="username">
 						<tmpl_var name="TEXT_USERNAME">

Deleted: trunk/vhffs-panel/templates/main/logout.tmpl
===================================================================
--- trunk/vhffs-panel/templates/main/logout.tmpl	2007-09-04 00:12:11 UTC (rev 863)
+++ trunk/vhffs-panel/templates/main/logout.tmpl	2007-09-04 17:34:02 UTC (rev 864)
@@ -1,27 +0,0 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd";>
-<html xmlns="http://www.w3.org/1999/xhtml";>
-	<head>
-	
-		<title><tmpl_var name="TITLE"></title>
-	
-		<link rel="stylesheet" type="text/css" href="/themes/<tmpl_var name="THEME">/main.css" />
-		<meta http-equiv="Pragma" content="no-cache" />
-		<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
-		<meta http-equiv="refresh" content="3; url=/auth.pl">
-		<tmpl_var name="HEADERS_SUP">
-		<tmpl_loop name="JSCRIPTS">
-		<script language="javascript" type="text/javascript" charset="utf-8" src="<tmpl_var name="SCRIPT">"></script>
-		</tmpl_loop>
-	</head>
-
-	<body>
-
-		<div class="logo"></div>
-		<div class="misc" id="misc">
-			<h1 class="message"><tmpl_var name="TEXT_LOGOUT"></h1>
-	
-			<p class="button"><a href="/auth.pl"><tmpl_var name="TEXT_LOGIN"></a></p>
-		</div>
-		
-	</body>
-</html>

Modified: trunk/vhffs-panel/templates/menu/main.tmpl
===================================================================
--- trunk/vhffs-panel/templates/menu/main.tmpl	2007-09-04 00:12:11 UTC (rev 863)
+++ trunk/vhffs-panel/templates/menu/main.tmpl	2007-09-04 17:34:02 UTC (rev 864)
@@ -24,7 +24,7 @@
             <a href="/alert.pl" title="<tmpl_var name="TEXT_SUBMITBUG">">
                 <img src="/themes/<tmpl_var name="THEME">/images/bug.png" title="<tmpl_var name="TEXT_SUBMITBUG">" alt="<tmpl_var name="TEXT_SUBMITBUG">" onmouseover="javascript:this.timer=helpTimeout('user_bug');" onmouseout="javascript:window.clearTimeout(this.timer);"/>
             </a>
-            <a href="/logout.pl" title="<tmpl_var name="TEXT_LOGOUT">">
+            <a href="/auth.pl?logout=1" title="<tmpl_var name="TEXT_LOGOUT">">
                 <img src="/themes/<tmpl_var name="THEME">/images/logout.png" title="<tmpl_var name="TEXT_LOGOUT">" alt="<tmpl_var name="TEXT_LOGOUT">" onmouseover="javascript:this.timer=helpTimeout('user_logout');" onmouseout="javascript:window.clearTimeout(this.timer);"/>
             </a>
         </div>

Modified: trunk/vhffs-panel/templates/menu/user.tmpl
===================================================================
--- trunk/vhffs-panel/templates/menu/user.tmpl	2007-09-04 00:12:11 UTC (rev 863)
+++ trunk/vhffs-panel/templates/menu/user.tmpl	2007-09-04 17:34:02 UTC (rev 864)
@@ -16,7 +16,7 @@
 					</a>
 				</li>
 				<li id="logout">
-					<a href="/logout.pl" title="<tmpl_var name="TEXT_LOGOUT">">
+					<a href="/auth.pl?logout=1" title="<tmpl_var name="TEXT_LOGOUT">">
 						<tmpl_var name="TEXT_LOGOUT">
 					</a>
 				</li>


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/