diff --git a/index.php b/index.php index 63ffba135a..bb1e370d24 100644 --- a/index.php +++ b/index.php @@ -63,7 +63,7 @@ elseif(isset($_COOKIE["oc_remember_login"]) && $_COOKIE["oc_remember_login"]) { OC_Util::redirectToDefaultPage(); } else { - OC_Template::printGuestPage("", "login", array("error" => true)); + OC_Util::displayLoginPage(array('error' => true)); } } @@ -83,11 +83,7 @@ elseif(isset($_POST["user"]) && isset($_POST['password'])) { OC_Util::redirectToDefaultPage(); } 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)); - } + OC_Util::displayLoginPage(array('error' => true)); } } @@ -126,11 +122,7 @@ elseif(isset($_GET['resetpassword']) && isset($_GET['token']) && isset($_GET['us // For all others cases, we display the guest page : else { OC_App::loadApps(); - if(isset($_COOKIE["username"])){ - OC_Template::printGuestPage("", "login", array("error" => false, "username" => $_COOKIE["username"])); - }else{ - OC_Template::printGuestPage("", "login", array("error" => false)); - } + OC_Util::displayLoginPage(array('error' => false)); } ?> diff --git a/lib/util.php b/lib/util.php index 51d8cc4d64..39cd1a7afa 100644 --- a/lib/util.php +++ b/lib/util.php @@ -247,6 +247,13 @@ class OC_Util { return $errors; } + public static function displayLoginPage($parameters = array()){ + if(isset($_COOKIE["username"])){ + $parameters["username"] = $_COOKIE["username"]; + } + OC_Template::printGuestPage("", "login", $parameters); + } + /** * Check if the user is logged in, redirects to home if not */