fix changing passwords
This commit is contained in:
parent
5a26640f63
commit
d47cdc3c18
|
@ -6,33 +6,32 @@ require_once('../../lib/base.php');
|
||||||
$l=new OC_L10N('settings');
|
$l=new OC_L10N('settings');
|
||||||
|
|
||||||
// We send json data
|
// We send json data
|
||||||
header( "Content-Type: application/jsonrequest" );
|
header("Content-Type: application/jsonrequest");
|
||||||
|
|
||||||
// Check if we are a user
|
// Check if we are a user
|
||||||
if( !OC_User::isLoggedIn()){
|
if(!OC_User::isLoggedIn()){
|
||||||
echo json_encode( array( "status" => "error", "data" => array( "message" => $l->t( "Authentication error" ) )));
|
echo json_encode(array("status" => "error", "data" => array("message" => $l->t("Authentication error"))));
|
||||||
exit();
|
exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get data
|
// Get data
|
||||||
if( !isset( $_POST["password"] ) && !isset( $_POST["oldpassword"] )){
|
if(!isset($_POST["password"]) && !isset($_POST["oldpassword"])){
|
||||||
echo json_encode( array( "status" => "error", "data" => array( "message" => $l->t( "You have to enter the old and the new password!" ) )));
|
echo json_encode(array("status" => "error", "data" => array("message" => $l->t("You have to enter the old and the new password!"))));
|
||||||
exit();
|
exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if the old password is correct
|
// Check if the old password is correct
|
||||||
if( !OC_User::checkPassword( $_SESSION["user_id"], $_POST["oldpassword"] )){
|
if(!OC_User::checkPassword($_SESSION["user_id"], $_POST["oldpassword"])){
|
||||||
echo json_encode( array( "status" => "error", "data" => array( "message" => $l->t("Your old password is wrong!") )));
|
echo json_encode(array("status" => "error", "data" => array("message" => $l->t("Your old password is wrong!"))));
|
||||||
exit();
|
exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Change password
|
// Change password
|
||||||
if( OC_User::setPassword( $_SESSION["user_id"], $_POST["password"] )){
|
if(OC_User::setPassword($_SESSION["user_id"], $_POST["password"])){
|
||||||
echo json_encode( array( "status" => "success", "data" => array( "message" => $l->t("Password changed") )));
|
echo json_encode(array("status" => "success", "data" => array("message" => $l->t("Password changed"))));
|
||||||
OC_Crypt::changekeypasscode( $_POST["password"]) {
|
OC_Crypt::changekeypasscode($_POST["password"]);
|
||||||
}
|
}else{
|
||||||
else{
|
echo json_encode(array("status" => "error", "data" => array("message" => $l->t("Unable to change password"))));
|
||||||
echo json_encode( array( "status" => "error", "data" => array( "message" => $l->t("Unable to change password") )));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
Loading…
Reference in New Issue