Code Duplication    Length = 3-5 lines in 3 locations

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

@@ 539-541 (lines=3) @@
536
537
		// If not permitted
538
		$subAdminManager = $this->groupManager->getSubAdmin();
539
		if(!$this->groupManager->isAdmin($currentLoggedInUser->getUID()) && !$subAdminManager->isUserAccessible($currentLoggedInUser, $targetUser)) {
540
			throw new OCSException('', \OCP\API::RESPOND_UNAUTHORISED);
541
		}
542
543
		// Go ahead with the delete
544
		if($targetUser->delete()) {
@@ 593-595 (lines=3) @@
590
591
		// If not permitted
592
		$subAdminManager = $this->groupManager->getSubAdmin();
593
		if(!$this->groupManager->isAdmin($currentLoggedInUser->getUID()) && !$subAdminManager->isUserAccessible($currentLoggedInUser, $targetUser)) {
594
			throw new OCSException('', \OCP\API::RESPOND_UNAUTHORISED);
595
		}
596
597
		// enable/disable the user now
598
		$targetUser->setEnabled($value);
@@ 901-905 (lines=5) @@
898
899
		// Check if admin / subadmin
900
		$subAdminManager = $this->groupManager->getSubAdmin();
901
		if(!$subAdminManager->isUserAccessible($currentLoggedInUser, $targetUser)
902
			&& !$this->groupManager->isAdmin($currentLoggedInUser->getUID())) {
903
			// No rights
904
			throw new OCSException('', \OCP\API::RESPOND_UNAUTHORISED);
905
		}
906
907
		$email = $targetUser->getEMailAddress();
908
		if ($email === '' || $email === null) {