Code Duplication    Length = 3-5 lines in 3 locations

apps/provisioning_api/lib/Controller/UsersController.php 3 locations

@@ 542-544 (lines=3) @@
539
540
		// If not permitted
541
		$subAdminManager = $this->groupManager->getSubAdmin();
542
		if (!$this->groupManager->isAdmin($currentLoggedInUser->getUID()) && !$subAdminManager->isUserAccessible($currentLoggedInUser, $targetUser)) {
543
			throw new OCSException('', \OCP\API::RESPOND_UNAUTHORISED);
544
		}
545
546
		// Go ahead with the delete
547
		if ($targetUser->delete()) {
@@ 596-598 (lines=3) @@
593
594
		// If not permitted
595
		$subAdminManager = $this->groupManager->getSubAdmin();
596
		if (!$this->groupManager->isAdmin($currentLoggedInUser->getUID()) && !$subAdminManager->isUserAccessible($currentLoggedInUser, $targetUser)) {
597
			throw new OCSException('', \OCP\API::RESPOND_UNAUTHORISED);
598
		}
599
600
		// enable/disable the user now
601
		$targetUser->setEnabled($value);
@@ 857-861 (lines=5) @@
854
855
		// Check if admin / subadmin
856
		$subAdminManager = $this->groupManager->getSubAdmin();
857
		if (!$subAdminManager->isUserAccessible($currentLoggedInUser, $targetUser)
858
			&& !$this->groupManager->isAdmin($currentLoggedInUser->getUID())) {
859
			// No rights
860
			throw new OCSException('', \OCP\API::RESPOND_UNAUTHORISED);
861
		}
862
863
		$email = $targetUser->getEMailAddress();
864
		if ($email === '' || $email === null) {