mirror of
https://github.com/nextcloud/server.git
synced 2026-05-28 04:32:30 -04:00
Changed behaviour of remember checkbox
This commit is contained in:
parent
8c7aa06088
commit
68e7666293
2 changed files with 40 additions and 9 deletions
34
index.php
34
index.php
|
|
@ -59,13 +59,14 @@ elseif(OC_User::isLoggedIn()) {
|
|||
}
|
||||
}
|
||||
|
||||
// Someone wants to log in :
|
||||
elseif(isset($_POST["user"]) && isset($_POST['password'])) {
|
||||
// Semeone set remember login when login
|
||||
elseif(isset($_COOKIE["oc_remember_login"]) && $_COOKIE["oc_remember_login"]) {
|
||||
OC_App::loadApps();
|
||||
if(OC_User::login($_POST["user"], $_POST["password"])) {
|
||||
header("Location: ".$WEBROOT.'/'.OC_Appconfig::getValue("core", "defaultpage", "files/index.php"));
|
||||
error_log("Trying to login from cookie");
|
||||
if(OC_User::login($_COOKIE["oc_username"], $_COOKIE["oc_password"])) {
|
||||
header("Location: ". $WEBROOT.'/'.OC_Appconfig::getValue("core", "defaultpage", "files/index.php"));
|
||||
if(!empty($_POST["remember_login"])){
|
||||
OC_User::setUsernameInCookie($_POST["user"]);
|
||||
OC_User::setUsernameInCookie($_POST["user"], $_POST["password"]);
|
||||
}
|
||||
else {
|
||||
OC_User::unsetUsernameInCookie();
|
||||
|
|
@ -81,6 +82,29 @@ elseif(isset($_POST["user"]) && isset($_POST['password'])) {
|
|||
}
|
||||
}
|
||||
|
||||
// Someone wants to log in :
|
||||
elseif(isset($_POST["user"]) && isset($_POST['password'])) {
|
||||
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"])){
|
||||
error_log("Setting remember login to cookie");
|
||||
OC_User::setUsernameInCookie($_POST["user"], $_POST["password"]);
|
||||
}
|
||||
else {
|
||||
OC_User::unsetUsernameInCookie();
|
||||
}
|
||||
exit();
|
||||
}
|
||||
else {
|
||||
if(isset($_COOKIE["oc_username"])){
|
||||
OC_Template::printGuestPage("", "login", array("error" => true, "username" => $_COOKIE["oc_username"]));
|
||||
}else{
|
||||
OC_Template::printGuestPage("", "login", array("error" => true));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Someone lost their password:
|
||||
elseif(isset($_GET['lostpassword'])) {
|
||||
OC_App::loadApps();
|
||||
|
|
|
|||
15
lib/user.php
15
lib/user.php
|
|
@ -215,6 +215,7 @@ class OC_User {
|
|||
public static function logout(){
|
||||
OC_Hook::emit( "OC_User", "logout", array());
|
||||
$_SESSION['user_id'] = false;
|
||||
OC_User::unsetUsernameInCookie();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -340,15 +341,21 @@ class OC_User {
|
|||
* @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);
|
||||
public static function setUsernameInCookie($username, $password){
|
||||
setcookie("oc_username", $username, time()+60*60*24*15);
|
||||
setcookie("oc_password", $password, time()+60*60*24*15);
|
||||
setcookie("oc_remember_login", true, time()+60*60*24*15);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Remove cookie for "remember username"
|
||||
*/
|
||||
public static function unsetUsernameInCookie(){
|
||||
unset($_COOKIE["username"]);
|
||||
setcookie("username", NULL, -1);
|
||||
unset($_COOKIE["oc_username"]);
|
||||
unset($_COOKIE["oc_password"]);
|
||||
unset($_COOKIE["oc_remember_login"]);
|
||||
setcookie("oc_username", NULL, -1);
|
||||
setcookie("oc_password", NULL, -1);
|
||||
setcookie("oc_remember_login", NULL, -1);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue