Code Duplication    Length = 3-5 lines in 3 locations

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

@@ 489-491 (lines=3) @@
486
487
		// If not permitted
488
		$subAdminManager = $this->groupManager->getSubAdmin();
489
		if(!$this->groupManager->isAdmin($currentLoggedInUser->getUID()) && !$subAdminManager->isUserAccessible($currentLoggedInUser, $targetUser)) {
490
			throw new OCSException('', \OCP\API::RESPOND_UNAUTHORISED);
491
		}
492
493
		// Go ahead with the delete
494
		if($targetUser->delete()) {
@@ 544-546 (lines=3) @@
541
542
		// If not permitted
543
		$subAdminManager = $this->groupManager->getSubAdmin();
544
		if(!$this->groupManager->isAdmin($currentLoggedInUser->getUID()) && !$subAdminManager->isUserAccessible($currentLoggedInUser, $targetUser)) {
545
			throw new OCSException('', \OCP\API::RESPOND_UNAUTHORISED);
546
		}
547
548
		// enable/disable the user now
549
		$targetUser->setEnabled($value);
@@ 843-847 (lines=5) @@
840
841
		// Check if admin / subadmin
842
		$subAdminManager = $this->groupManager->getSubAdmin();
843
		if(!$subAdminManager->isUserAccessible($currentLoggedInUser, $targetUser)
844
			&& !$this->groupManager->isAdmin($currentLoggedInUser->getUID())) {
845
			// No rights
846
			throw new OCSException('', \OCP\API::RESPOND_UNAUTHORISED);
847
		}
848
849
		$email = $targetUser->getEMailAddress();
850
		if ($email === '' || $email === null) {