remember login added
This commit is contained in:
parent
6230001a3c
commit
c5776fdae4
|
@ -107,7 +107,10 @@ div.controls { width:91%; margin:1em 1em 1em 2em; padding:0.5em 0; background-co
|
||||||
background-color: #666;
|
background-color: #666;
|
||||||
color: #FFF;
|
color: #FFF;
|
||||||
}
|
}
|
||||||
|
#login_form input[type="checkbox"]
|
||||||
|
{
|
||||||
|
width:15px;
|
||||||
|
}
|
||||||
|
|
||||||
#setup_form {
|
#setup_form {
|
||||||
margin: 3em auto;
|
margin: 3em auto;
|
||||||
|
|
|
@ -5,8 +5,15 @@
|
||||||
<?php if($_['error']): ?>
|
<?php if($_['error']): ?>
|
||||||
<?php echo $l->t( 'Login failed!' ); ?>
|
<?php echo $l->t( 'Login failed!' ); ?>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
|
<?php if(empty($_["username"])){?>
|
||||||
<input type="text" name="user" id="user" value="" autofocus />
|
<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="" />
|
<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" />
|
<input type="submit" value="Log in" />
|
||||||
</fieldset>
|
</fieldset>
|
||||||
</form>
|
</form>
|
||||||
|
|
11
index.php
11
index.php
|
@ -31,7 +31,6 @@ OC_UTIL::addScript('setup');
|
||||||
|
|
||||||
$not_installed = !OC_CONFIG::getValue('installed', false);
|
$not_installed = !OC_CONFIG::getValue('installed', false);
|
||||||
$install_called = (isset($_POST['install']) AND $_POST['install']=='true');
|
$install_called = (isset($_POST['install']) AND $_POST['install']=='true');
|
||||||
|
|
||||||
// First step : check if the server is correctly configured for ownCloud :
|
// First step : check if the server is correctly configured for ownCloud :
|
||||||
$errors = OC_UTIL::checkServer();
|
$errors = OC_UTIL::checkServer();
|
||||||
if(count($errors) > 0) {
|
if(count($errors) > 0) {
|
||||||
|
@ -61,17 +60,23 @@ elseif(isset($_POST["user"])) {
|
||||||
OC_APP::loadApps();
|
OC_APP::loadApps();
|
||||||
if(OC_USER::login($_POST["user"], $_POST["password"])) {
|
if(OC_USER::login($_POST["user"], $_POST["password"])) {
|
||||||
header("Location: ".$WEBROOT.'/'.OC_APPCONFIG::getValue("core", "defaultpage", "files/index.php"));
|
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();
|
exit();
|
||||||
}
|
}
|
||||||
else {
|
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 :
|
// For all others cases, we display the guest page :
|
||||||
else {
|
else {
|
||||||
OC_APP::loadApps();
|
OC_APP::loadApps();
|
||||||
OC_TEMPLATE::printGuestPage("", "login", array("error" => false));
|
OC_TEMPLATE::printGuestPage("", "login", array("error" => false, "username" => $_COOKIE["username"]));
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
16
lib/user.php
16
lib/user.php
|
@ -337,4 +337,20 @@ class OC_USER {
|
||||||
}
|
}
|
||||||
return false;
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue