Code Duplication    Length = 6-8 lines in 3 locations

lib/private/User/Session.php 3 locations

@@ 753-758 (lines=6) @@
750
751
		$this->manager->emit('\OC\User', 'postLogin', [$user, $password]);
752
753
		if ($this->isLoggedIn()) {
754
			$this->prepareUserLogin(false);
755
		} else {
756
			$message = \OC::$server->getL10N('lib')->t('Login canceled by app');
757
			throw new LoginException($message);
758
		}
759
760
		return true;
761
	}
@@ 478-485 (lines=8) @@
475
			$this->setLoginName($uid);
476
			$firstTimeLogin = $user->updateLastLoginTimestamp();
477
			$this->manager->emit('\OC\User', 'postLogin', [$user, $password]);
478
			if ($this->isLoggedIn()) {
479
				$this->prepareUserLogin($firstTimeLogin);
480
				return true;
481
			} else {
482
				// injecting l10n does not work - there is a circular dependency between session and \OCP\L10N\IFactory
483
				$message = \OC::$server->getL10N('lib')->t('Login canceled by app');
484
				throw new LoginException($message);
485
			}
486
		} else {
487
			// injecting l10n does not work - there is a circular dependency between session and \OCP\L10N\IFactory
488
			$message = \OC::$server->getL10N('lib')->t('User disabled');
@@ 535-541 (lines=7) @@
532
		$this->setLoginName($dbToken->getLoginName());
533
		$this->manager->emit('\OC\User', 'postLogin', [$user, $password]);
534
535
		if ($this->isLoggedIn()) {
536
			$this->prepareUserLogin();
537
		} else {
538
			// injecting l10n does not work - there is a circular dependency between session and \OCP\L10N\IFactory
539
			$message = \OC::$server->getL10N('lib')->t('Login canceled by app');
540
			throw new LoginException($message);
541
		}
542
543
		// set the app password
544
		$this->session->set('app_password', $token);