Code Duplication    Length = 3-5 lines in 3 locations

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

@@ 575-577 (lines=3) @@
572
573
		// If not permitted
574
		$subAdminManager = $this->groupManager->getSubAdmin();
575
		if(!$this->groupManager->isAdmin($currentLoggedInUser->getUID()) && !$subAdminManager->isUserAccessible($currentLoggedInUser, $targetUser)) {
576
			throw new OCSException('', \OCP\API::RESPOND_UNAUTHORISED);
577
		}
578
579
		// Go ahead with the delete
580
		if($targetUser->delete()) {
@@ 629-631 (lines=3) @@
626
627
		// If not permitted
628
		$subAdminManager = $this->groupManager->getSubAdmin();
629
		if(!$this->groupManager->isAdmin($currentLoggedInUser->getUID()) && !$subAdminManager->isUserAccessible($currentLoggedInUser, $targetUser)) {
630
			throw new OCSException('', \OCP\API::RESPOND_UNAUTHORISED);
631
		}
632
633
		// enable/disable the user now
634
		$targetUser->setEnabled($value);
@@ 946-950 (lines=5) @@
943
944
		// Check if admin / subadmin
945
		$subAdminManager = $this->groupManager->getSubAdmin();
946
		if(!$subAdminManager->isUserAccessible($currentLoggedInUser, $targetUser)
947
			&& !$this->groupManager->isAdmin($currentLoggedInUser->getUID())) {
948
			// No rights
949
			throw new OCSException('', \OCP\API::RESPOND_UNAUTHORISED);
950
		}
951
952
		$email = $targetUser->getEMailAddress();
953
		if ($email === '' || $email === null) {