Logs in after password recovery and xnet account activation.
authorStéphane Jacob <sj@m4x.org>
Thu, 17 Mar 2011 23:04:59 +0000 (00:04 +0100)
committerStéphane Jacob <sj@m4x.org>
Sun, 20 Mar 2011 23:06:45 +0000 (00:06 +0100)
Signed-off-by: Stéphane Jacob <sj@m4x.org>
classes/xnetsession.php
htdocs/javascript/xorg.js
modules/platal.php
modules/xnet.php
templates/admin/accounts.tpl
templates/admin/user.tpl
templates/googleapps/index.tpl
templates/platal/password.tpl
templates/register/step3.tpl
templates/xnet/edit.tpl
templates/xnetgrp/membres-edit.tpl

index 90cf11c..765ad5e 100644 (file)
@@ -34,7 +34,7 @@ class XnetSession extends XorgSession
             }
         }
 
-        if (!S::logged() && Post::has('auth_type') && Post::v('auth_type') == 'xnet') {
+        if (!S::logged() && Post::has('auth_type') && Post::v('auth_type') == 'xnet' && !Post::has('wait')) {
             $type = XDB::fetchOneCell('SELECT  type
                                          FROM  accounts
                                         WHERE  hruid = {?}',
index b262759..0a1a478 100644 (file)
@@ -566,7 +566,7 @@ function checkPassword(box, okLabel) {
     }
 }
 
-function hashResponse(password1, password2, hasConfirmation) {
+function hashResponse(password1, password2, hasConfirmation, doAuth) {
     var pw1 = $('[name=' + password1 + ']').val();
     var pw2;
 
@@ -593,6 +593,12 @@ function hashResponse(password1, password2, hasConfirmation) {
     alert("Le mot de passe va être chiffré avant de nous parvenir par Internet ! Ainsi il ne circulera pas en clair.");
     $('[name=' + password1 + ']').val('');
     $('[name=pwhash]').val(hash_encrypt(pw1));
+
+    if (doAuth) {
+        $('[name=password]').val(pw1);
+        doChallengeResponse();
+    }
+
     return true;
 }
 
index 3be5bc1..29821a6 100644 (file)
@@ -383,9 +383,19 @@ Adresse de secours : " . Post::v('email') : ""));
             }
 
             S::logger($uid)->log("passwd", "");
+
+            // Try to start a session (so the user don't have to log in); we will use
+            // the password available in Post:: to authenticate the user.
+            Platal::session()->start(AUTH_MDP);
+
             $page->changeTpl('platal/tmpPWD.success.tpl');
         } else {
+            $hruid = XDB::fetchOneCell('SELECT  hruid
+                                          FROM  accounts
+                                         WHERE  uid = {?}',
+                                       $uid);
             $page->changeTpl('platal/password.tpl');
+            $page->assign('hruid', $hruid);
         }
     }
 
index 607b30c..e0fada4 100644 (file)
@@ -259,11 +259,18 @@ class XnetModule extends PLModule
                        $res['uid']);
 
             S::logger($res['uid'])->log('passwd', '');
+
+            // Try to start a session (so the user don't have to log in); we will use
+            // the password available in Post:: to authenticate the user.
+            Post::kill('wait');
+            Platal::session()->startAvailableAuth();
+
             $page->changeTpl('xnet/register.success.tpl');
             $page->assign('hruid', $res['hruid']);
         } else {
             $page->changeTpl('platal/password.tpl');
             $page->assign('xnet', true);
+            $page->assign('hruid', $res['hruid']);
         }
     }
 
index fece962..a6dad0d 100644 (file)
@@ -119,7 +119,7 @@ function add_user_to_url(f) {
         <tr>
           <td colspan="2" class="center">
             <input type="submit" name="create_account" value="Créer le compte"
-                   onclick="return hashResponse('password', false, false);" />
+                   onclick="return hashResponse('password', false, false, false);" />
           </td>
         </tr>
       </table>
index 1d478a3..d9f35b1 100644 (file)
@@ -252,7 +252,7 @@ $(function() {
     </tr>
     <tr class="impair">
       <td colspan="2" class="center">
-        <input type="submit" name="update_account" value="Mettre à jour" onclick="return hashResponse('new_plain_password', false, false);" />
+        <input type="submit" name="update_account" value="Mettre à jour" onclick="return hashResponse('new_plain_password', false, false, false);" />
         <input type="submit" name="su_account" value="Prendre l'identité" />
         <input type="submit" name="log_account" value="Consulter les logs" />
         {if $user->state neq 'pending'}
index 54d8391..70bb0fc 100644 (file)
           <input type="submit" value="Créer mon compte !" />
         {else}
           <input type="hidden" name="pwhash" value="" />
-          <input type="submit" name="create_account" value="Créer mon compte !" onclick="return hashResponse('new1', 'new2', true);" />
+          <input type="submit" name="create_account" value="Créer mon compte !" onclick="return hashResponse('new1', 'new2', true, false);" />
         {/if}
       </td>
     </tr>
           <td></td>
           <td>
             <input type="hidden" name="pwhash" value="" />
-            <input type="submit" name="create_account" value="Changer" onclick="return hashResponse('new1', 'new2', true);" />
+            <input type="submit" name="create_account" value="Changer" onclick="return hashResponse('new1', 'new2', true, false);" />
           </td>
         </tr>
       </table>
index a0632cd..02cdee2 100644 (file)
@@ -37,7 +37,7 @@
 <br />
 <fieldset style="width: 70%; margin-left: 15%">
   <legend>{icon name=lock} Saisie du {if !t($xnet)}nouveau {/if}mot de passe</legend>
-  <form action="{$smarty.server.REQUEST_URI}" method="post">
+  <form action="{$smarty.server.REQUEST_URI}" method="post" id="login">
   {xsrf_token_field}
     <table style="width: 100%">
       <tr>
         </td>
       </tr>
       <tr>
+        <td>
+          <input type="hidden" name="username" value="{$hruid}" />
+          <input type="hidden" name="password" value="" />
+          <input type="hidden" name="domain" value="ax" />
+        </td>
+        <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="hidden" name="pwhash" value="" />
-          <input type="submit" value="{if t($xnet)}Créer{else}Changer{/if}" name="submitn" onclick="return hashResponse('new1', 'new2', true);" />
+          <input type="submit" value="{if t($xnet)}Créer{else}Changer{/if}" name="submitn" onclick="return hashResponse('new1', 'new2', true, true);" />
         </td>
       </tr>
     </table>
   </form>
 </fieldset>
 
+<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="{if t($xnet)}xnet{/if}" />
+    <input type="hidden" name="pwhash"    value="" />
+    {if t($xnet)}<input type="hidden" name="wait" />{/if}
+  </div>
+</form>
+
 {if !t($xnet)}
 <p>
   Note bien qu'il s'agit là du mot de passe te permettant de t'authentifier sur le site {#globals.core.sitename#}&nbsp;;
index ae9cf64..e6e9385 100644 (file)
     </tr>
     <tr class="impair">
       <td class="center">
-        <input type="submit" name="submitn" value="Continuer" onclick="return hashResponse('password1', 'password2', true);" />
+        <input type="submit" name="submitn" value="Continuer" onclick="return hashResponse('password1', 'password2', true, false);" />
       </td>
     </tr>
   </table>
index f00c1e7..71ae196 100644 (file)
 
   <div class="center">
     <br />
-    <input type="submit" name='change' value="Valider ces changements" onclick="return hashResponse('password1', 'password2', true);" />
+    <input type="submit" name='change' value="Valider ces changements" onclick="return hashResponse('password1', 'password2', true, false);" />
     &nbsp;
     <input type="reset" value="Annuler ces changements" />
   </div>
index 12e1da1..0df7c6a 100644 (file)
 
   <div class="center">
     <br />
-    <input type="submit" name='change' value="Valider ces changements" onclick="return hashResponse('new_plain_password', false, false);" />
+    <input type="submit" name='change' value="Valider ces changements" onclick="return hashResponse('new_plain_password', false, false, false);" />
     &nbsp;
     <input type="reset" value="Annuler ces changements" />
   </div>