Code Duplication    Length = 3-5 lines in 3 locations

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

@@ 421-423 (lines=3) @@
418
419
		// If not permitted
420
		$subAdminManager = $this->groupManager->getSubAdmin();
421
		if(!$this->groupManager->isAdmin($currentLoggedInUser->getUID()) && !$subAdminManager->isUserAccessible($currentLoggedInUser, $targetUser)) {
422
			throw new OCSException('', \OCP\API::RESPOND_UNAUTHORISED);
423
		}
424
425
		// Go ahead with the delete
426
		if($targetUser->delete()) {
@@ 476-478 (lines=3) @@
473
474
		// If not permitted
475
		$subAdminManager = $this->groupManager->getSubAdmin();
476
		if(!$this->groupManager->isAdmin($currentLoggedInUser->getUID()) && !$subAdminManager->isUserAccessible($currentLoggedInUser, $targetUser)) {
477
			throw new OCSException('', \OCP\API::RESPOND_UNAUTHORISED);
478
		}
479
480
		// enable/disable the user now
481
		$targetUser->setEnabled($value);
@@ 775-779 (lines=5) @@
772
773
		// Check if admin / subadmin
774
		$subAdminManager = $this->groupManager->getSubAdmin();
775
		if(!$subAdminManager->isUserAccessible($currentLoggedInUser, $targetUser)
776
			&& !$this->groupManager->isAdmin($currentLoggedInUser->getUID())) {
777
			// No rights
778
			throw new OCSException('', \OCP\API::RESPOND_UNAUTHORISED);
779
		}
780
781
		$email = $targetUser->getEMailAddress();
782
		if ($email === '' || $email === null) {