From: Bartek Przybylski Date: Wed, 20 Jul 2011 13:04:14 +0000 (+0200) Subject: remember login added X-Git-Tag: v3.0~267^2~397 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=c5776fdae4c6ae1fbad1831946d2e6ba4fa0ffac;p=nextcloud-server.git remember login added --- diff --git a/core/css/styles.css b/core/css/styles.css index f0dfd1e9b15..678ad009d1a 100644 --- a/core/css/styles.css +++ b/core/css/styles.css @@ -107,7 +107,10 @@ div.controls { width:91%; margin:1em 1em 1em 2em; padding:0.5em 0; background-co background-color: #666; color: #FFF; } - +#login_form input[type="checkbox"] +{ + width:15px; +} #setup_form { margin: 3em auto; diff --git a/core/templates/login.php b/core/templates/login.php index 0ed4178a984..7c0efa9fa4f 100644 --- a/core/templates/login.php +++ b/core/templates/login.php @@ -5,8 +5,15 @@ t( 'Login failed!' ); ?> + + t('Remember login'); ?> + + + t('Remember login'); ?> + + diff --git a/index.php b/index.php index d1726676c66..2e2d495fda6 100644 --- a/index.php +++ b/index.php @@ -31,7 +31,6 @@ OC_UTIL::addScript('setup'); $not_installed = !OC_CONFIG::getValue('installed', false); $install_called = (isset($_POST['install']) AND $_POST['install']=='true'); - // First step : check if the server is correctly configured for ownCloud : $errors = OC_UTIL::checkServer(); if(count($errors) > 0) { @@ -61,17 +60,23 @@ elseif(isset($_POST["user"])) { OC_APP::loadApps(); if(OC_USER::login($_POST["user"], $_POST["password"])) { header("Location: ".$WEBROOT.'/'.OC_APPCONFIG::getValue("core", "defaultpage", "files/index.php")); + if(!empty($_POST["remember_login"])){ + OC_USER::setUsernameInCookie($_POST["user"]); + } + else { + OC_USER::unsetUsernameInCookie(); + } exit(); } else { - OC_TEMPLATE::printGuestPage("", "login", array("error" => true)); + OC_TEMPLATE::printGuestPage("", "login", array("error" => true, "username" => $_COOKIE["username"])); } } // For all others cases, we display the guest page : else { OC_APP::loadApps(); - OC_TEMPLATE::printGuestPage("", "login", array("error" => false)); + OC_TEMPLATE::printGuestPage("", "login", array("error" => false, "username" => $_COOKIE["username"])); } ?> \ No newline at end of file diff --git a/lib/user.php b/lib/user.php index 25f555b47b1..a64ce05f2c9 100644 --- a/lib/user.php +++ b/lib/user.php @@ -337,4 +337,20 @@ class OC_USER { } return false; } + + /** + * @brief Set cookie value to use in next page load + * @param string $username username to be set + */ + public static function setUsernameInCookie($username){ + setcookie("username", $username, mktime().time()+60*60*24*15); + } + + /** + * @brief Remove cookie for "remember username" + */ + public static function unsetUsernameInCookie(){ + unset($_COOKIE["username"]); + setcookie("username", NULL, -1); + } }