Code Duplication    Length = 6-8 lines in 3 locations

lib/private/User/Session.php 3 locations

@@ 778-783 (lines=6) @@
775
776
		$this->manager->emit('\OC\User', 'postLogin', [$user, $password]);
777
778
		if ($this->isLoggedIn()) {
779
			$this->prepareUserLogin(false);
780
		} else {
781
			$message = \OC::$server->getL10N('lib')->t('Login canceled by app');
782
			throw new LoginException($message);
783
		}
784
785
		return true;
786
	}
@@ 479-486 (lines=8) @@
476
			$this->setLoginName($uid);
477
			$firstTimeLogin = $user->updateLastLoginTimestamp();
478
			$this->manager->emit('\OC\User', 'postLogin', [$user, $password]);
479
			if ($this->isLoggedIn()) {
480
				$this->prepareUserLogin($firstTimeLogin);
481
				return true;
482
			} else {
483
				// injecting l10n does not work - there is a circular dependency between session and \OCP\L10N\IFactory
484
				$message = \OC::$server->getL10N('lib')->t('Login canceled by app');
485
				throw new LoginException($message);
486
			}
487
		} else {
488
			// injecting l10n does not work - there is a circular dependency between session and \OCP\L10N\IFactory
489
			$message = \OC::$server->getL10N('lib')->t('User disabled');
@@ 536-542 (lines=7) @@
533
		$this->setLoginName($dbToken->getLoginName());
534
		$this->manager->emit('\OC\User', 'postLogin', [$user, $password]);
535
536
		if ($this->isLoggedIn()) {
537
			$this->prepareUserLogin();
538
		} else {
539
			// injecting l10n does not work - there is a circular dependency between session and \OCP\L10N\IFactory
540
			$message = \OC::$server->getL10N('lib')->t('Login canceled by app');
541
			throw new LoginException($message);
542
		}
543
544
		// set the app password
545
		$this->session->set('app_password', $token);