Code Duplication    Length = 3-5 lines in 3 locations

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

@@ 444-446 (lines=3) @@
441
442
		// If not permitted
443
		$subAdminManager = $this->groupManager->getSubAdmin();
444
		if(!$this->groupManager->isAdmin($currentLoggedInUser->getUID()) && !$subAdminManager->isUserAccessible($currentLoggedInUser, $targetUser)) {
445
			throw new OCSException('', \OCP\API::RESPOND_UNAUTHORISED);
446
		}
447
448
		// Go ahead with the delete
449
		if($targetUser->delete()) {
@@ 499-501 (lines=3) @@
496
497
		// If not permitted
498
		$subAdminManager = $this->groupManager->getSubAdmin();
499
		if(!$this->groupManager->isAdmin($currentLoggedInUser->getUID()) && !$subAdminManager->isUserAccessible($currentLoggedInUser, $targetUser)) {
500
			throw new OCSException('', \OCP\API::RESPOND_UNAUTHORISED);
501
		}
502
503
		// enable/disable the user now
504
		$targetUser->setEnabled($value);
@@ 798-802 (lines=5) @@
795
796
		// Check if admin / subadmin
797
		$subAdminManager = $this->groupManager->getSubAdmin();
798
		if(!$subAdminManager->isUserAccessible($currentLoggedInUser, $targetUser)
799
			&& !$this->groupManager->isAdmin($currentLoggedInUser->getUID())) {
800
			// No rights
801
			throw new OCSException('', \OCP\API::RESPOND_UNAUTHORISED);
802
		}
803
804
		$email = $targetUser->getEMailAddress();
805
		if ($email === '' || $email === null) {