Skip to content
Snippets Groups Projects
Verified Commit 244a2f2b authored by Florian Azizian's avatar Florian Azizian
Browse files

FIX #16832 TIME 0:20 can change ws user password if no default connection enabled

parent 0974d0dd
No related branches found
No related tags found
No related merge requests found
...@@ -563,15 +563,16 @@ class UserController ...@@ -563,15 +563,16 @@ class UserController
public function updatePassword(Request $request, Response $response, array $args) public function updatePassword(Request $request, Response $response, array $args)
{ {
$connection = ConfigurationModel::getConnection();
if ($connection != 'default') {
return $response->withStatus(403)->withJson(['errors' => 'Privilege forbidden']);
}
if (!Validator::intVal()->notEmpty()->validate($args['id'])) { if (!Validator::intVal()->notEmpty()->validate($args['id'])) {
return $response->withStatus(400)->withJson(['errors' => 'Route id is not an integer']); return $response->withStatus(400)->withJson(['errors' => 'Route id is not an integer']);
} }
$user = UserModel::getById(['select' => ['login', '"isRest"'], 'id' => $args['id']]);
$connection = ConfigurationModel::getConnection();
if ($connection != 'default' && $user['isRest'] == false) {
return $response->withStatus(403)->withJson(['errors' => 'Privilege forbidden']);
}
if ($GLOBALS['id'] != $args['id']) { if ($GLOBALS['id'] != $args['id']) {
if (!PrivilegeController::hasPrivilege(['userId' => $GLOBALS['id'], 'privilege' => 'manage_users'])) { if (!PrivilegeController::hasPrivilege(['userId' => $GLOBALS['id'], 'privilege' => 'manage_users'])) {
return $response->withStatus(403)->withJson(['errors' => 'Privilege forbidden']); return $response->withStatus(403)->withJson(['errors' => 'Privilege forbidden']);
...@@ -585,8 +586,6 @@ class UserController ...@@ -585,8 +586,6 @@ class UserController
return $response->withStatus(400)->withJson(['errors' => 'Body newPassword and passwordConfirmation must be identical']); return $response->withStatus(400)->withJson(['errors' => 'Body newPassword and passwordConfirmation must be identical']);
} }
$user = UserModel::getById(['select' => ['login', '"isRest"'], 'id' => $args['id']]);
if ($user['isRest'] == false) { if ($user['isRest'] == false) {
if (empty($body['currentPassword']) || !AuthenticationModel::authentication(['login' => $user['login'], 'password' => $body['currentPassword']])) { if (empty($body['currentPassword']) || !AuthenticationModel::authentication(['login' => $user['login'], 'password' => $body['currentPassword']])) {
return $response->withStatus(401)->withJson(['errors' => 'Wrong Password', 'lang' => 'wrongCurrentPassword']); return $response->withStatus(401)->withJson(['errors' => 'Wrong Password', 'lang' => 'wrongCurrentPassword']);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment