diff --git a/code/ryzom/tools/server/ryzom_ams/ams_lib/autoload/users.php b/code/ryzom/tools/server/ryzom_ams/ams_lib/autoload/users.php index 7373bc4a3..640849011 100644 --- a/code/ryzom/tools/server/ryzom_ams/ams_lib/autoload/users.php +++ b/code/ryzom/tools/server/ryzom_ams/ams_lib/autoload/users.php @@ -365,25 +365,27 @@ class Users{ } } - protected function setPassword($user, $pass){ + protected function setAmsPassword($user, $pass){ + + global $cfg; + $values = Array('user' => $user, 'pass' => $pass); + try { //make connection with and put into shard db - global $cfg; $dbs = new DBLayer($cfg['db']['shard']); $dbs->execute("UPDATE user SET Password = :pass WHERE Login = :user ",$values); return "ok"; } catch (PDOException $e) { //oh noooz, the shard is offline! Put in query queue at ams_lib db! - /*try { - $dbl = new DBLayer($cfg['db']['lib']); - $dbl->execute("INSERT INTO ams_querycache (type, query) VALUES (:type, :query)",array("type" => "createUser", - "query" => json_encode(array($values["name"],$values["pass"],$values["mail"])))); + try { + $dbl = new DBLayer($cfg['db']['lib']); + $dbl->execute("INSERT INTO ams_querycache (type, query) VALUES (:type, :query)",array("type" => "changepass", + "query" => json_encode(array($values["name"],$values["pass"])))); return "shardoffline"; }catch (PDOException $e) { - print_r($e); return "liboffline"; - }*/ + } } } } diff --git a/code/ryzom/tools/server/ryzom_ams/www/html/autoload/webusers.php b/code/ryzom/tools/server/ryzom_ams/www/html/autoload/webusers.php index 91c7bc317..4427fa578 100644 --- a/code/ryzom/tools/server/ryzom_ams/www/html/autoload/webusers.php +++ b/code/ryzom/tools/server/ryzom_ams/www/html/autoload/webusers.php @@ -74,4 +74,19 @@ class WebUsers extends Users{ return false; } + public function setPassword($user, $pass){ + global $cfg; + $reply = WebUsers::setAmsPassword($user, $pass); + $values = Array('user' => $user, 'pass' => $pass); + try { + //make connection with and put into shard db + $dbw = new DBLayer($cfg['db']['web']); + $dbw->execute("UPDATE ams_user SET Password = :pass WHERE Login = :user ",$values); + } + catch (PDOException $e) { + //ERROR: the web DB is offline + } + return $reply; + } + } \ No newline at end of file diff --git a/code/ryzom/tools/server/ryzom_ams/www/html/func/change_password.php b/code/ryzom/tools/server/ryzom_ams/www/html/func/change_password.php index 3603c5144..05da2655b 100644 --- a/code/ryzom/tools/server/ryzom_ams/www/html/func/change_password.php +++ b/code/ryzom/tools/server/ryzom_ams/www/html/func/change_password.php @@ -25,8 +25,23 @@ function change_password(){ $result = $webUser->check_change_password($params); if ($result == "success"){ //edit stuff into db + $hashpass = crypt($_POST["NewPass"], WebUsers::generateSALT()); - print('success!'); + $status = WebUsers::setPassword($target_username, $hashpass); + if($status == 'ok'){ + $succresult['SUCCESS'] = "OK"; + }else if($status == 'shardoffline'){ + $succresult['SUCCESS'] = "SHARDOFF"; + } + $succresult['permission'] = $_SESSION['permission']; + $succresult['no_visible_elements'] = 'FALSE'; + $succresult['target_id'] = $_POST['target_id']; + if(isset($_GET['id'])){ + if(WebUsers::isAdmin() && ($_POST['target_id'] != $_SESSION['id'])){ + $succresult['isAdmin'] = "TRUE"; + } + } + helpers :: loadtemplate( 'settings', $succresult); exit; }else{ diff --git a/code/ryzom/tools/server/ryzom_ams/www/html/func/login.php b/code/ryzom/tools/server/ryzom_ams/www/html/func/login.php index a34203541..3a4d8a489 100644 --- a/code/ryzom/tools/server/ryzom_ams/www/html/func/login.php +++ b/code/ryzom/tools/server/ryzom_ams/www/html/func/login.php @@ -18,6 +18,7 @@ function login(){ exit; }else{ //handle login failure + $result = Array(); $result['login_error'] = 'TRUE'; $result['no_visible_elements'] = 'TRUE'; helpers :: loadtemplate( 'login', $result); diff --git a/code/ryzom/tools/server/ryzom_ams/www/html/templates/settings.tpl b/code/ryzom/tools/server/ryzom_ams/www/html/templates/settings.tpl index c0e4f7a7b..2606cee35 100644 --- a/code/ryzom/tools/server/ryzom_ams/www/html/templates/settings.tpl +++ b/code/ryzom/tools/server/ryzom_ams/www/html/templates/settings.tpl @@ -50,6 +50,20 @@ + + + {if isset($SUCCESS) and $SUCCESS eq "OK"} +