mirror of
https://port.numenaute.org/aleajactaest/khanat-code-old.git
synced 2024-11-10 09:19:01 +00:00
changepassword works
This commit is contained in:
parent
a94bb6dbc7
commit
2a1b8f9dd2
5 changed files with 56 additions and 9 deletions
|
@ -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";
|
||||
}*/
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
|
@ -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{
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -50,6 +50,20 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
{if isset($SUCCESS) and $SUCCESS eq "OK"}
|
||||
<div class="alert alert-success">
|
||||
Your password has been changed!
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
{if isset($SUCCESS) and $SUCCESS eq "SHARDOFF"}
|
||||
<div class="alert alert-warning">
|
||||
Your password has been changed, though the shard seems offline, it may take some time to see the change on the shard.
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
<input type="hidden" name="function" value="change_password">
|
||||
<input type="hidden" name="target_id" value="{$target_id}">
|
||||
<div class="control-group">
|
||||
|
|
Loading…
Reference in a new issue