]> dev.renevier.net Git - syj.git/commitdiff
remember me checkbox for login
authorarno <arno@renevier.net>
Sun, 20 Mar 2011 13:22:45 +0000 (14:22 +0100)
committerarno <arno@renevier.net>
Sun, 20 Mar 2011 14:46:56 +0000 (15:46 +0100)
application/controllers/LoginController.php
application/controllers/helpers/SyjUserManager.php
application/forms/Login.php
application/languages/lang_en.po
application/languages/lang_fr.po
application/languages/lang_ja.po

index 85c7ac1541a972c3966d5a6798146167531a2704..4c8aca05771e224d0ed73629fab566998d589d2b 100644 (file)
@@ -32,7 +32,9 @@ class LoginController extends Zend_Controller_Action
         }
 
         /* form has been filled */
-        if (!$this->_helper->SyjUserManager->validate($formData['login_user'], sha1($formData['login_password']))) {
+        if (!$this->_helper->SyjUserManager->validate($formData['login_user'],
+                                                     sha1($formData['login_password']),
+                                                     $formData['login_rememberme'])) {
             if ($httprequest) {
                 throw new Syj_Exception_Forbidden();
             } else {
index 427e6faa07434d3e9f215e3f3b6adad67edb6c17..d1f8a600c5a52ac5c7c992914a5b48756c671fee 100644 (file)
@@ -7,7 +7,7 @@ class Syj_Controller_Action_Helper_SyjUserManager extends Zend_Controller_Action
     // -1 for undeterminated, null for non logged, Syj_Model_User for a logged user
     protected static $_current = -1;
 
-    static public function validate($username, $hash) {
+    static public function validate($username, $hash, $rememberme = false) {
         // TODO: try to make only one sql request
         $adapter = Zend_Db_Table_Abstract::getDefaultAdapter();
         $authAdapter = new Zend_Auth_Adapter_DbTable($adapter, 'users', 'pseudo', 'password');
@@ -26,8 +26,14 @@ class Syj_Controller_Action_Helper_SyjUserManager extends Zend_Controller_Action
         }
 
         if (!isset ($_COOKIE['syj_user']) or (!isset ($_COOKIE['syj_hashpass']))) {
-            setcookie("syj_user", $username, 0, "", "", false, true);
-            setcookie("syj_hashpass", $hash, 0, "", "", false, true);
+            if ($rememberme) {
+                // cookie will be valid for 2 weeks
+                $time = time () + 14 * 60 * 24 * 60;
+            } else {
+                $time = 0;
+            }
+            setcookie("syj_user", $username, $time, "", "", false, true);
+            setcookie("syj_hashpass", $hash, $time, "", "", false, true);
         }
         self::$_current = $user;
         return true;
index a13692aa3136d9cae030758b8fc2b2fe252d59af..33fdfe7a39efdc6560a2b549ced0115278f7cc75 100644 (file)
@@ -9,8 +9,8 @@ class Syj_Form_Login extends Syj_Form_TableAbstract
         $user = array('Text', 'login_user', array( 'label' => __("user"), 'required' => true));
         $pass = array('Password', 'login_password', array( 'label' => __("password")));
 
-
         $this->setMainElements(array($user, $pass))
+             ->addElement('Checkbox', 'login_rememberme', array( 'label' => __("remember me"), 'checked' => true))
              ->addElement('Hidden', 'login_geom_id', array( 'decorators' => array('ViewHelper')));
 
         $currentUri = $this->getView()->UriPath(true);
index 79510dfaa427c7ed2177eb26bbaa9746d4b4f247..a56b04514ea85b2a3f2760389f85a774af26d8a2 100644 (file)
@@ -2,7 +2,7 @@ msgid ""
 msgstr ""
 "Project-Id-Version: syj\n"
 "Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2011-03-18 17:25+0100\n"
+"POT-Creation-Date: 2011-03-20 14:22+0100\n"
 "PO-Revision-Date: \n"
 "Last-Translator: arno <arno@renevier.net>\n"
 "Language-Team: arno <arno@renevier.net>\n"
@@ -436,7 +436,7 @@ msgstr ""
 "\n"
 "Syj team"
 
-#: application/controllers/LoginController.php:99
+#: application/controllers/LoginController.php:91
 #: application/controllers/IdxController.php:160
 msgid "you must enter a login name"
 msgstr "you must enter a login name"
@@ -689,6 +689,10 @@ msgstr "user"
 msgid "password"
 msgstr "password"
 
+#: application/forms/Login.php:13
+msgid "remember me"
+msgstr "remember me"
+
 #: application/forms/Login.php:20
 msgid "I forgot my password"
 msgstr "I forgot my password"
@@ -801,3 +805,4 @@ msgstr "Someone, probably you, has registered an account %s with email address %
 #: application/forms/Pending/ValidateCreation.php:24
 msgid "To cancel account creation, press following button. The account and all its data will be deleted."
 msgstr "To cancel account creation, press following button. The account and all its data will be deleted."
+
index aa161a9a5cc5a54d95fe3d28922435e8813d7c9b..266912728c5e156550422fee1fcd0d93db513664 100644 (file)
@@ -2,7 +2,7 @@ msgid ""
 msgstr ""
 "Project-Id-Version: syj\n"
 "Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2011-03-18 17:25+0100\n"
+"POT-Creation-Date: 2011-03-20 14:22+0100\n"
 "PO-Revision-Date: \n"
 "Last-Translator: arno <arno@renevier.net>\n"
 "Language-Team: arno <arno@renevier.net>\n"
@@ -438,7 +438,7 @@ msgstr ""
 "\n"
 "L'équipe de Syj"
 
-#: application/controllers/LoginController.php:99
+#: application/controllers/LoginController.php:91
 #: application/controllers/IdxController.php:160
 msgid "you must enter a login name"
 msgstr "vous devez entrer un nom d'utilisateur"
@@ -691,6 +691,10 @@ msgstr "utilisateur"
 msgid "password"
 msgstr "mot de passe"
 
+#: application/forms/Login.php:13
+msgid "remember me"
+msgstr "se souvenir de moi"
+
 #: application/forms/Login.php:20
 msgid "I forgot my password"
 msgstr "J'ai oublié mon mot de passe"
@@ -803,3 +807,4 @@ msgstr "Quelqu'un, probablement vous, a enregistré un compte %s avec l'adresse
 #: application/forms/Pending/ValidateCreation.php:24
 msgid "To cancel account creation, press following button. The account and all its data will be deleted."
 msgstr "Pour annuler la création du compte, pressez le bouton suivant. Le compte ainsi que toutes ses données seront supprimés."
+
index 1c270c3d205578e07939109e0c4f525ff9736dc4..b7f63d4daa3dbcd3f92c589541b636939586578a 100644 (file)
@@ -2,7 +2,7 @@ msgid ""
 msgstr ""
 "Project-Id-Version: syj\n"
 "Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2011-03-18 17:25+0100\n"
+"POT-Creation-Date: 2011-03-20 14:22+0100\n"
 "PO-Revision-Date: \n"
 "Last-Translator: S.Higashi <s_higash@mua.biglobe.ne.jp>\n"
 "Language: \n"
@@ -531,7 +531,7 @@ msgstr ""
 "\n"
 "Syj チーム"
 
-#: application/controllers/LoginController.php:99
+#: application/controllers/LoginController.php:91
 #: application/controllers/IdxController.php:160
 msgid "you must enter a login name"
 msgstr "ログイン名を入力してください"
@@ -785,6 +785,10 @@ msgstr "ユーザ"
 msgid "password"
 msgstr "パスワード"
 
+#: application/forms/Login.php:13
+msgid "remember me"
+msgstr ""
+
 #: application/forms/Login.php:20
 msgid "I forgot my password"
 msgstr "パスワードを忘れた"