Code Duplication    Length = 6-8 lines in 4 locations

lib/private/User/Session.php 4 locations

@@ 640-647 (lines=8) @@
637
638
			$firstTimeLogin = $user->updateLastLoginTimestamp();
639
			$this->manager->emit('\OC\User', 'postLogin', [$user, '']);
640
			if ($this->isLoggedIn()) {
641
				$this->prepareUserLogin($firstTimeLogin);
642
				return true;
643
			} else {
644
				// injecting l10n does not work - there is a circular dependency between session and \OCP\L10N\IFactory
645
				$message = \OC::$server->getL10N('lib')->t('Login canceled by app');
646
				throw new LoginException($message);
647
			}
648
		} else {
649
			// injecting l10n does not work - there is a circular dependency between session and \OCP\L10N\IFactory
650
			$message = \OC::$server->getL10N('lib')->t('User disabled');
@@ 498-505 (lines=8) @@
495
				$this->setLoginName($uid);
496
				$firstTimeLogin = $user->updateLastLoginTimestamp();
497
				$this->manager->emit('\OC\User', 'postLogin', [$user, $password]);
498
				if ($this->isLoggedIn()) {
499
					$this->prepareUserLogin($firstTimeLogin);
500
					return true;
501
				} else {
502
					// injecting l10n does not work - there is a circular dependency between session and \OCP\L10N\IFactory
503
					$message = \OC::$server->getL10N('lib')->t('Login canceled by app');
504
					throw new LoginException($message);
505
				}
506
			} else {
507
				// injecting l10n does not work - there is a circular dependency between session and \OCP\L10N\IFactory
508
				$message = \OC::$server->getL10N('lib')->t('User disabled');
@@ 556-562 (lines=7) @@
553
		$this->setLoginName($dbToken->getLoginName());
554
		$this->manager->emit('\OC\User', 'postLogin', [$user, $password]);
555
556
		if ($this->isLoggedIn()) {
557
			$this->prepareUserLogin();
558
		} else {
559
			// injecting l10n does not work - there is a circular dependency between session and \OCP\L10N\IFactory
560
			$message = \OC::$server->getL10N('lib')->t('Login canceled by app');
561
			throw new LoginException($message);
562
		}
563
564
		// set the app password
565
		$this->session->set('app_password', $token);
@@ 860-865 (lines=6) @@
857
858
			$this->manager->emit('\OC\User', 'postLogin', [$user, $password]);
859
860
			if ($this->isLoggedIn()) {
861
				$this->prepareUserLogin();
862
			} else {
863
				$message = \OC::$server->getL10N('lib')->t('Login canceled by app');
864
				throw new LoginException($message);
865
			}
866
867
			return true;
868
		}, ['before' => ['uid' => $user, 'password' => $password], 'after' => ['uid' => $user, 'password' => $password]], 'user', 'login');