diff --git a/core/css/styles.css b/core/css/styles.css index f0dfd1e9b1..678ad009d1 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 0ed4178a98..7c0efa9fa4 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 d1726676c6..2e2d495fda 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 25f555b47b..a64ce05f2c 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); + } }