From: Bart Visscher Date: Fri, 30 Sep 2011 21:48:20 +0000 (+0200) Subject: Merge branch 'lostpassword' X-Git-Tag: v3.0~101^2~22 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=21a88613a150c550e32d63df9a9ef8bf3d5107d0;p=nextcloud-server.git Merge branch 'lostpassword' Conflicts: core/templates/login.php index.php lib/util.php --- 21a88613a150c550e32d63df9a9ef8bf3d5107d0 diff --cc core/templates/login.php index 641e0adb6e0,c8a86d71a91..6564847014b --- a/core/templates/login.php +++ b/core/templates/login.php @@@ -1,17 -1,17 +1,17 @@@
- + - t('Lost your password?'); ?> + t('Lost your password?'); ?> - + - - - - + + autocomplete="off" required /> + /> + - - - + + + - +
diff --cc index.php index 68754fcc567,0db8ad126ce..17429b97476 --- a/index.php +++ b/index.php @@@ -81,40 -81,9 +81,8 @@@ elseif(isset($_POST["user"]) && isset($ OC_User::unsetMagicInCookie(); } OC_Util::redirectToDefaultPage(); - } - else { + } else { - OC_Template::printGuestPage('', 'login', array('error' => true, 'username' => isset($_COOKIE['oc_username'])?$_COOKIE['oc_username']:'' )); - } - } - - // Someone lost their password: - elseif(isset($_GET['lostpassword'])) { - OC_App::loadApps(); - if (isset($_POST['user'])) { - if (OC_User::userExists($_POST['user'])) { - $token = sha1($_POST['user']+uniqId()); - OC_Preferences::setValue($_POST['user'], "owncloud", "lostpassword", $token); - // TODO send email with link+token - OC_Template::printGuestPage("", "lostpassword", array("error" => false, "requested" => true)); - } else { - OC_Template::printGuestPage("", "lostpassword", array("error" => true, "requested" => false)); - } - } else { - OC_Template::printGuestPage("", "lostpassword", array("error" => false, "requested" => false)); - } - } - - // Someone wants to reset their password: - elseif(isset($_GET['resetpassword']) && isset($_GET['token']) && isset($_GET['user']) && OC_Preferences::getValue($_GET['user'], "owncloud", "lostpassword") === $_GET['token']) { - OC_App::loadApps(); - if (isset($_POST['password'])) { - if (OC_User::setPassword($_GET['user'], $_POST['password'])) { - OC_Preferences::deleteKey($_GET['user'], "owncloud", "lostpassword"); - OC_Template::printGuestPage("", "resetpassword", array("success" => true)); - } else { - OC_Template::printGuestPage("", "resetpassword", array("success" => false)); - } - } else { - OC_Template::printGuestPage("", "resetpassword", array("success" => false)); + OC_Util::displayLoginPage(array('error' => true)); } } diff --cc lib/util.php index 26d718da944,39cd1a7afab..f21ec8208b4 --- a/lib/util.php +++ b/lib/util.php @@@ -258,34 -247,13 +258,42 @@@ class OC_Util return $errors; } + public static function displayLoginPage($parameters = array()){ + if(isset($_COOKIE["username"])){ + $parameters["username"] = $_COOKIE["username"]; ++ } else { ++ $parameters["username"] = ''; + } + OC_Template::printGuestPage("", "login", $parameters); + } + /** + * Try to get the username the httpd server runs on, used in hints + */ + public static function checkWebserverUser(){ + $stat=stat($_SERVER['DOCUMENT_ROOT']); + if(is_callable('posix_getpwuid')){ + $serverUser=posix_getpwuid($stat['uid']); + $serverUser='\''.$serverUser['name'].'\''; + }elseif(exec('whoami')){ + $serverUser=exec('whoami'); + }else{ + $serverUser='\'www-data\' for ubuntu/debian'; //TODO: try to detect the distro and give a guess based on that + } + return $serverUser; + } + + + /** + * Check if the app is enabled, send json error msg if not + */ + public static function checkAppEnabled($app){ + if( !OC_App::isEnabled($app)){ + header( 'Location: '.OC_Helper::linkTo( '', 'index.php' , true)); + exit(); + } + } + /** * Check if the user is logged in, redirects to home if not */