Code Duplication    Length = 6-7 lines in 2 locations

lib/private/User/Session.php 2 locations

@@ 598-604 (lines=7) @@
595
		$afterEvent = new GenericEvent(null, ['loginType' => 'token', 'user' => $user, 'login' => $user->getUID(), 'password' => $password]);
596
		$this->eventDispatcher->dispatch('user.afterlogin', $afterEvent);
597
598
		if ($this->isLoggedIn()) {
599
			$this->prepareUserLogin();
600
		} else {
601
			// injecting l10n does not work - there is a circular dependency between session and \OCP\L10N\IFactory
602
			$message = \OC::$server->getL10N('lib')->t('Login canceled by app');
603
			throw new LoginException($message);
604
		}
605
606
		// set the app password
607
		$this->session->set('app_password', $token);
@@ 1002-1007 (lines=6) @@
999
1000
			$this->manager->emit('\OC\User', 'postLogin', [$user, $password]);
1001
1002
			if ($this->isLoggedIn()) {
1003
				$this->prepareUserLogin();
1004
			} else {
1005
				$message = \OC::$server->getL10N('lib')->t('Login canceled by app');
1006
				throw new LoginException($message);
1007
			}
1008
1009
			return true;
1010
		}, ['before' => ['user' => $user, 'uid' => $uid, 'password' => $password],