diff options
author | Bartek Przybylski <bart.p.pl@gmail.com> | 2011-07-20 15:04:14 +0200 |
---|---|---|
committer | Bartek Przybylski <bart.p.pl@gmail.com> | 2011-07-20 15:04:14 +0200 |
commit | c5776fdae4c6ae1fbad1831946d2e6ba4fa0ffac (patch) | |
tree | bb9e9bcdea3899f0a0a7d19cb765d2692b55c54d | |
parent | 6230001a3c80c081001c46197cc95403cc73622f (diff) | |
download | nextcloud-server-c5776fdae4c6ae1fbad1831946d2e6ba4fa0ffac.tar.gz nextcloud-server-c5776fdae4c6ae1fbad1831946d2e6ba4fa0ffac.zip |
remember login added
-rw-r--r-- | core/css/styles.css | 5 | ||||
-rw-r--r-- | core/templates/login.php | 7 | ||||
-rw-r--r-- | index.php | 11 | ||||
-rw-r--r-- | lib/user.php | 16 |
4 files changed, 35 insertions, 4 deletions
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 @@ <?php if($_['error']): ?> <?php echo $l->t( 'Login failed!' ); ?> <?php endif; ?> + <?php if(empty($_["username"])){?> <input type="text" name="user" id="user" value="" autofocus /> + <input type="checkbox" name="remember_login"/> <?php echo $l->t('Remember login'); ?> <input type="password" name="password" id="password" value="" /> + <?php }else{ ?> + <input type="text" name="user" id="user" value="<?php echo $_['username']; ?>"> + <input type="checkbox" name="remember_login" checked /> <?php echo $l->t('Remember login'); ?> + <input type="password" name="password" id="password" value="" autofocus /> + <?php } ?> <input type="submit" value="Log in" /> </fieldset> </form> 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); + } } |