Code Duplication    Length = 3-5 lines in 3 locations

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

@@ 438-440 (lines=3) @@
435
436
		// If not permitted
437
		$subAdminManager = $this->groupManager->getSubAdmin();
438
		if(!$this->groupManager->isAdmin($currentLoggedInUser->getUID()) && !$subAdminManager->isUserAccessible($currentLoggedInUser, $targetUser)) {
439
			throw new OCSException('', \OCP\API::RESPOND_UNAUTHORISED);
440
		}
441
442
		// Go ahead with the delete
443
		if($targetUser->delete()) {
@@ 493-495 (lines=3) @@
490
491
		// If not permitted
492
		$subAdminManager = $this->groupManager->getSubAdmin();
493
		if(!$this->groupManager->isAdmin($currentLoggedInUser->getUID()) && !$subAdminManager->isUserAccessible($currentLoggedInUser, $targetUser)) {
494
			throw new OCSException('', \OCP\API::RESPOND_UNAUTHORISED);
495
		}
496
497
		// enable/disable the user now
498
		$targetUser->setEnabled($value);
@@ 792-796 (lines=5) @@
789
790
		// Check if admin / subadmin
791
		$subAdminManager = $this->groupManager->getSubAdmin();
792
		if(!$subAdminManager->isUserAccessible($currentLoggedInUser, $targetUser)
793
			&& !$this->groupManager->isAdmin($currentLoggedInUser->getUID())) {
794
			// No rights
795
			throw new OCSException('', \OCP\API::RESPOND_UNAUTHORISED);
796
		}
797
798
		$email = $targetUser->getEMailAddress();
799
		if ($email === '' || $email === null) {