public function actionChangePassword() { $params = array('cimba_auth_id', 'old_password', 'new_password'); try { $isRequestValid = $this->_validator->validateRequest($params); if ($isRequestValid) { $cimbaAuthId = $this->_request->getParam('cimba_auth_id', null); $newPassword = $this->_request->getParam('new_password'); $oldPassword = $this->_request->getParam('old_password'); $objUsersModel = new \models\Users(); // check if password matches the required criteria or not $isPatternMatched = preg_match('/^(?=.*[a-z])(?=.*[A-Z])(?=.*\\d)(?=.*[$@$!%*?&])[A-Za-z\\d$@$!%*?&]{9,15}$/', $newPassword); if ($isPatternMatched) { //change password $isPasswordChanged = $objUsersModel->changePassword($cimbaAuthId, $oldPassword, $newPassword); if ($isPasswordChanged === true) { $this->_response->renderJson(array('message' => 'User password successfully changed', 'success' => '1'), 200); } elseif ($isPasswordChanged === -4) { $this->_response->renderJson(array('message' => 'Invalid Old Password', 'success' => '0'), 200); } else { $this->_response->renderJson(array('message' => 'Error updating password', "success" => '0'), 200); } } else { $this->_response->renderJson(array('message' => 'Please enter minimum 9 and maximum 15 characters at least 1 uppercase alphabet, 1 lowercase alphabet, 1 number and 1 special character', 'success' => '0'), 200); } } else { $this->_response->renderJson(array('message' => 'Request cannot be validated'), 400); } } catch (\Exception $e) { $this->_response->renderJson(array('message' => $e->getMessage()), 500); } }