Adds login page for xnet users (Closes #1211).
authorStéphane Jacob <sj@m4x.org>
Mon, 14 Mar 2011 21:41:51 +0000 (22:41 +0100)
committerStéphane Jacob <sj@m4x.org>
Wed, 16 Mar 2011 16:46:52 +0000 (17:46 +0100)
Signed-off-by: Stéphane Jacob <sj@m4x.org>
ChangeLog
classes/xnetsession.php
include/xnet.inc.php
modules/xnet.php
templates/xnet/login.tpl [new file with mode: 0644]
templates/xnet/skin.tpl

index 53e5758..62fb6e1 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -28,6 +28,9 @@ Bug/Wish:
         - #1389: Do not require validation for private names modifications -JAC
         - #1401: Main addresses are displayed before secondary addresses   -JAC
 
+    * Xnet:
+        - #1211: Adds login page for xnet users                            -JAC
+
     * XnetGrp:
         - #907: Adds more info about groups (address, phones, positions)   -JAC
 
index 2833d32..90cf11c 100644 (file)
@@ -34,6 +34,25 @@ class XnetSession extends XorgSession
             }
         }
 
+        if (!S::logged() && Post::has('auth_type') && Post::v('auth_type') == 'xnet') {
+            $type = XDB::fetchOneCell('SELECT  type
+                                         FROM  accounts
+                                        WHERE  hruid = {?}',
+                                      Post::v('username'));
+            if (!is_null($type) && $type != 'xnet') {
+                Platal::page()->trigErrorRedirect('Ce formulaire d\'authentification est réservé aux extérieurs à la communauté polytechnicienne.', '');
+            }
+
+            $user = parent::doAuth(AUTH_MDP);
+            if (is_null($user)) {
+                return false;
+            }
+            if (!parent::checkAuth(AUTH_MDP) || !parent::startSessionAs($user, AUTH_MDP)) {
+                $this->destroy();
+                return false;
+            }
+        }
+
         global $globals;
         if (!S::logged() && $globals->xnet->auth_baseurl) {
             // prevent connection to be linked to disconnection
index a57e421..a2d1c22 100644 (file)
@@ -26,6 +26,7 @@ define('PL_SESSION_CLASS', 'XnetSession');
 define('PL_PAGE_CLASS', 'XnetPage');
 
 require_once dirname(dirname(__FILE__)) . '/core/include/platal.inc.php';
+require_once 'security.inc.php';
 require_once 'common.inc.php';
 
 // vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
index e0b5f00..627824c 100644 (file)
@@ -33,6 +33,7 @@ class XnetModule extends PLModule
             'plan'        => $this->make_hook('plan',      AUTH_PUBLIC),
             'photo'       => $this->make_hook('photo',     AUTH_MDP),
             'autologin'   => $this->make_hook('autologin', AUTH_MDP),
+            'login/ext'   => $this->make_hook('login_ext', AUTH_PUBLIC),
             'edit'        => $this->make_hook('edit',      AUTH_MDP, 'user'),
 
             'Xnet'        => $this->make_wiki_hook(),
@@ -225,6 +226,15 @@ class XnetModule extends PLModule
         exit;
     }
 
+    function handler_login_ext($page)
+    {
+        if (!S::logged()) {
+            $page->changeTpl('xnet/login.tpl');
+        } else {
+            pl_redirect('');
+        }
+    }
+
     function handler_edit(&$page)
     {
         global $globals;
diff --git a/templates/xnet/login.tpl b/templates/xnet/login.tpl
new file mode 100644 (file)
index 0000000..f92b8cb
--- /dev/null
@@ -0,0 +1,64 @@
+{**************************************************************************}
+{*                                                                        *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
+{*  http://opensource.polytechnique.org/                                  *}
+{*                                                                        *}
+{*  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.                                   *}
+{*                                                                        *}
+{*  This program is distributed in the hope that it will be useful,       *}
+{*  but WITHOUT ANY WARRANTY; without even the implied warranty of        *}
+{*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *}
+{*  GNU General Public License for more details.                          *}
+{*                                                                        *}
+{*  You should have received a copy of the GNU General Public License     *}
+{*  along with this program; if not, write to the Free Software           *}
+{*  Foundation, Inc.,                                                     *}
+{*  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA               *}
+{*                                                                        *}
+{**************************************************************************}
+
+<h1>Identification</h1>
+
+<form action="{$smarty.server.REQUEST_URI}" method="post" id="login" onsubmit='doChallengeResponse(); return false;'>
+  <table class="bicol">
+    <tr>
+      <td class="titre">Identifiant&nbsp;:</td>
+      <td>
+        <input type="text" name="username" />
+        <input type="hidden" name="domain" value="ax" />
+      </td>
+    </tr>
+    <tr>
+      <td class="titre">Mot de passe&nbsp;:</td>
+      <td><input type="password" name="password" size="10" maxlength="256" /></td>
+    </tr>
+    <tr>
+      <td {popup caption='Connexion permanente' width='300' text='Décocher cette case pour que le site oublie ce navigateur.<br />
+        Il est conseillé de décocher la case si cette machine n\'est pas <b>strictement</b> personnelle'} colspan="2">
+        <label><input type="checkbox" name="remember" checked="checked" />
+          Garder l'accès aux services après déconnexion.
+        </label>
+      </td>
+    </tr>
+    <tr>
+      <td colspan="2" class="center"><input  type="submit" name="submitbtn" value="Envoyer" /></td>
+    </tr>
+  </table>
+</form>
+
+<form action="{$smarty.server.REQUEST_URI}" method="post" id="loginsub">
+  <div>
+    <input type="hidden" name="challenge" value="{$smarty.session.challenge}" />
+    <input type="hidden" name="username"  value="" />
+    <input type="hidden" name="remember"  value="" />
+    <input type="hidden" name="response"  value="" />
+    <input type="hidden" name="xorpass"   value="" /> 
+    <input type="hidden" name="domain"    value="" />
+    <input type="hidden" name="auth_type" value="xnet" />
+  </div>
+</form>
+
+{* vim:set et sw=2 sts=2 sws=2 enc=utf-8: *}
index 05cb391..b395e5e 100644 (file)
               {list_all_my_groups}
               {if !$smarty.session.auth}
                 <div>Me connecter&nbsp;:</div>
-                <a class='gp' href="login/{if $platal->pl_self() eq 'exit'}index{else}{$platal->pl_self()}{/if}">polytechnicien</a>
-                {if $platal->pl_self() neq 'exit'}
-                  <!-- <script type="text/javascript" src="login/autologin/{$platal->pl_self()}?forceXml=1"></script> -->
-                {/if}
+                <table style="margin-left: 1em">
+                  <tr>
+                    <td>
+                      <a class="gp" href="login/{if $platal->pl_self() eq 'exit'}index{else}{$platal->pl_self()}{/if}">X, masters, doctorants&hellip;</a>
+                    </td>
+                  </tr>
+                  <tr>
+                    <td><a class="gp" href="login/ext">Extérieurs</a></td>
+                  </tr>
+                </table>
               {/if}
             </td>
             <td class="right" style="vertical-align: middle">