mirror of
https://port.numenaute.org/aleajactaest/khanat-opennel-code.git
synced 2024-11-11 17:59:03 +00:00
changepassword works
This commit is contained in:
parent
ad9f32c191
commit
b6d55190e8
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 {
|
try {
|
||||||
//make connection with and put into shard db
|
//make connection with and put into shard db
|
||||||
global $cfg;
|
|
||||||
$dbs = new DBLayer($cfg['db']['shard']);
|
$dbs = new DBLayer($cfg['db']['shard']);
|
||||||
$dbs->execute("UPDATE user SET Password = :pass WHERE Login = :user ",$values);
|
$dbs->execute("UPDATE user SET Password = :pass WHERE Login = :user ",$values);
|
||||||
return "ok";
|
return "ok";
|
||||||
}
|
}
|
||||||
catch (PDOException $e) {
|
catch (PDOException $e) {
|
||||||
//oh noooz, the shard is offline! Put in query queue at ams_lib db!
|
//oh noooz, the shard is offline! Put in query queue at ams_lib db!
|
||||||
/*try {
|
try {
|
||||||
$dbl = new DBLayer($cfg['db']['lib']);
|
$dbl = new DBLayer($cfg['db']['lib']);
|
||||||
$dbl->execute("INSERT INTO ams_querycache (type, query) VALUES (:type, :query)",array("type" => "createUser",
|
$dbl->execute("INSERT INTO ams_querycache (type, query) VALUES (:type, :query)",array("type" => "changepass",
|
||||||
"query" => json_encode(array($values["name"],$values["pass"],$values["mail"]))));
|
"query" => json_encode(array($values["name"],$values["pass"]))));
|
||||||
return "shardoffline";
|
return "shardoffline";
|
||||||
}catch (PDOException $e) {
|
}catch (PDOException $e) {
|
||||||
print_r($e);
|
|
||||||
return "liboffline";
|
return "liboffline";
|
||||||
}*/
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -74,4 +74,19 @@ class WebUsers extends Users{
|
||||||
return false;
|
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);
|
$result = $webUser->check_change_password($params);
|
||||||
if ($result == "success"){
|
if ($result == "success"){
|
||||||
//edit stuff into db
|
//edit stuff into db
|
||||||
|
|
||||||
$hashpass = crypt($_POST["NewPass"], WebUsers::generateSALT());
|
$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;
|
exit;
|
||||||
|
|
||||||
}else{
|
}else{
|
||||||
|
|
|
@ -18,6 +18,7 @@ function login(){
|
||||||
exit;
|
exit;
|
||||||
}else{
|
}else{
|
||||||
//handle login failure
|
//handle login failure
|
||||||
|
$result = Array();
|
||||||
$result['login_error'] = 'TRUE';
|
$result['login_error'] = 'TRUE';
|
||||||
$result['no_visible_elements'] = 'TRUE';
|
$result['no_visible_elements'] = 'TRUE';
|
||||||
helpers :: loadtemplate( 'login', $result);
|
helpers :: loadtemplate( 'login', $result);
|
||||||
|
|
|
@ -50,6 +50,20 @@
|
||||||
</div>
|
</div>
|
||||||
</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="function" value="change_password">
|
||||||
<input type="hidden" name="target_id" value="{$target_id}">
|
<input type="hidden" name="target_id" value="{$target_id}">
|
||||||
<div class="control-group">
|
<div class="control-group">
|
||||||
|
|
Loading…
Reference in a new issue