diff options
author | Marvin Thomas Rabe <m.rabe@echtzeitraum.de> | 2011-10-01 11:08:49 +0200 |
---|---|---|
committer | Marvin Thomas Rabe <m.rabe@echtzeitraum.de> | 2011-10-01 11:08:49 +0200 |
commit | c943f48547c686570dac3d678672693e7b46658e (patch) | |
tree | 55933fc7cd0a70ad6231894fde064292fd2521b2 /index.php | |
parent | 0514a1925bb726cc23ae4b99ed85c4b5451357cc (diff) | |
download | nextcloud-server-c943f48547c686570dac3d678672693e7b46658e.tar.gz nextcloud-server-c943f48547c686570dac3d678672693e7b46658e.zip |
fixed link to password recovery. removed duplicated and unused code out of index.php.
Diffstat (limited to 'index.php')
-rw-r--r-- | index.php | 67 |
1 files changed, 33 insertions, 34 deletions
diff --git a/index.php b/index.php index 17429b97476..fb8d1922dd4 100644 --- a/index.php +++ b/index.php @@ -52,44 +52,43 @@ elseif(OC_User::isLoggedIn()) { } } -// remember was checked after last login -elseif(isset($_COOKIE["oc_remember_login"]) && isset($_COOKIE["oc_token"]) && isset($_COOKIE["oc_username"]) && $_COOKIE["oc_remember_login"]) { +// For all others cases, we display the guest page : +else { OC_App::loadApps(); - if(defined("DEBUG") && DEBUG) {error_log("Trying to login from cookie");} - // confirm credentials in cookie - if(isset($_COOKIE['oc_token']) && OC_User::userExists($_COOKIE['oc_username']) && - OC_Preferences::getValue($_COOKIE['oc_username'], "login", "token") == $_COOKIE['oc_token']) { - OC_User::setUserId($_COOKIE['oc_username']); - OC_Util::redirectToDefaultPage(); - } - else { - OC_Util::displayLoginPage(array('error' => true)); - } -} + $error = false; -// Someone wants to log in : -elseif(isset($_POST["user"]) && isset($_POST['password'])) { - OC_App::loadApps(); - if(OC_User::login($_POST["user"], $_POST["password"])) { - if(!empty($_POST["remember_login"])){ - if(defined("DEBUG") && DEBUG) {error_log("Setting remember login to cookie");} - $token = md5($_POST["user"].time()); - OC_Preferences::setValue($_POST['user'], 'login', 'token', $token); - OC_User::setMagicInCookie($_POST["user"], $token); + // remember was checked after last login + if(isset($_COOKIE["oc_remember_login"]) && isset($_COOKIE["oc_token"]) && isset($_COOKIE["oc_username"]) && $_COOKIE["oc_remember_login"]) { + if(defined("DEBUG") && DEBUG) { + error_log("Trying to login from cookie"); } - else { - OC_User::unsetMagicInCookie(); + // confirm credentials in cookie + if(isset($_COOKIE['oc_token']) && OC_User::userExists($_COOKIE['oc_username']) && + OC_Preferences::getValue($_COOKIE['oc_username'], "login", "token") == $_COOKIE['oc_token']) { + OC_User::setUserId($_COOKIE['oc_username']); + OC_Util::redirectToDefaultPage(); + } + } + + // Someone wants to log in : + elseif(isset($_POST["user"]) && isset($_POST['password'])) { + if(OC_User::login($_POST["user"], $_POST["password"])) { + if(!empty($_POST["remember_login"])){ + if(defined("DEBUG") && DEBUG) { + error_log("Setting remember login to cookie"); + } + $token = md5($_POST["user"].time()); + OC_Preferences::setValue($_POST['user'], 'login', 'token', $token); + OC_User::setMagicInCookie($_POST["user"], $token); + } + else { + OC_User::unsetMagicInCookie(); + } + OC_Util::redirectToDefaultPage(); + } else { + $error = true; } - OC_Util::redirectToDefaultPage(); - } else { - OC_Util::displayLoginPage(array('error' => true)); } -} -// For all others cases, we display the guest page : -else { - OC_App::loadApps(); - OC_Util::displayLoginPage(array('error' => false)); + OC_Template::printGuestPage('', 'login', array('error' => $error )); } - -?> |