Code Duplication    Length = 5-7 lines in 3 locations

settings/ChangePassword/Controller.php 2 locations

@@ 45-49 (lines=5) @@
42
		$password = isset($_POST['personal-password']) ? $_POST['personal-password'] : null;
43
		$oldPassword = isset($_POST['oldpassword']) ? $_POST['oldpassword'] : '';
44
45
		if (!\OC_User::checkPassword($username, $oldPassword)) {
46
			$l = \OC::$server->getL10NFactory()->get('settings');
47
			\OC_JSON::error(["data" => ["message" => $l->t("Wrong password")]]);
48
			exit();
49
		}
50
		if ($oldPassword === $password) {
51
			$l = \OC::$server->getL10NFactory()->get('settings');
52
			\OC_JSON::error(["data" => ["message" => $l->t("The new password can not be the same as the previous one")]]);
@@ 50-54 (lines=5) @@
47
			\OC_JSON::error(["data" => ["message" => $l->t("Wrong password")]]);
48
			exit();
49
		}
50
		if ($oldPassword === $password) {
51
			$l = \OC::$server->getL10NFactory()->get('settings');
52
			\OC_JSON::error(["data" => ["message" => $l->t("The new password can not be the same as the previous one")]]);
53
			exit();
54
	        }
55
		try {
56
			if (!is_null($password) && \OC_User::setPassword($username, $password)) {
57
				\OC::$server->getUserSession()->updateSessionTokenPassword($password);

settings/ajax/togglegroups.php 1 location

@@ 49-55 (lines=7) @@
46
	$isGroupAccessible = \OC::$server->getGroupManager()->getSubAdmin()->isSubAdminofGroup($currentUserObject, $targetGroupObject);
47
}
48
49
if(!OC_User::isAdminUser(OC_User::getUser())
50
	&& (!$isUserAccessible
51
		|| !$isGroupAccessible)) {
52
	$l = \OC::$server->getL10N('core');
53
	OC_JSON::error(['data' => ['message' => $l->t('Authentication error')]]);
54
	exit();
55
}
56
57
if (is_null($targetUserObject)) {
58
	OC_JSON::error(['data' => ['message' => $l->t('Unknown user')]]);