Chain.php 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * SPDX-FileCopyrightText: 2019 Nextcloud GmbH and Nextcloud contributors
  5. * SPDX-License-Identifier: AGPL-3.0-or-later
  6. */
  7. namespace OC\Authentication\Login;
  8. class Chain {
  9. /** @var PreLoginHookCommand */
  10. private $preLoginHookCommand;
  11. /** @var UserDisabledCheckCommand */
  12. private $userDisabledCheckCommand;
  13. /** @var UidLoginCommand */
  14. private $uidLoginCommand;
  15. /** @var EmailLoginCommand */
  16. private $emailLoginCommand;
  17. /** @var LoggedInCheckCommand */
  18. private $loggedInCheckCommand;
  19. /** @var CompleteLoginCommand */
  20. private $completeLoginCommand;
  21. /** @var CreateSessionTokenCommand */
  22. private $createSessionTokenCommand;
  23. /** @var ClearLostPasswordTokensCommand */
  24. private $clearLostPasswordTokensCommand;
  25. /** @var UpdateLastPasswordConfirmCommand */
  26. private $updateLastPasswordConfirmCommand;
  27. /** @var SetUserTimezoneCommand */
  28. private $setUserTimezoneCommand;
  29. /** @var TwoFactorCommand */
  30. private $twoFactorCommand;
  31. /** @var FinishRememberedLoginCommand */
  32. private $finishRememberedLoginCommand;
  33. public function __construct(PreLoginHookCommand $preLoginHookCommand,
  34. UserDisabledCheckCommand $userDisabledCheckCommand,
  35. UidLoginCommand $uidLoginCommand,
  36. EmailLoginCommand $emailLoginCommand,
  37. LoggedInCheckCommand $loggedInCheckCommand,
  38. CompleteLoginCommand $completeLoginCommand,
  39. CreateSessionTokenCommand $createSessionTokenCommand,
  40. ClearLostPasswordTokensCommand $clearLostPasswordTokensCommand,
  41. UpdateLastPasswordConfirmCommand $updateLastPasswordConfirmCommand,
  42. SetUserTimezoneCommand $setUserTimezoneCommand,
  43. TwoFactorCommand $twoFactorCommand,
  44. FinishRememberedLoginCommand $finishRememberedLoginCommand
  45. ) {
  46. $this->preLoginHookCommand = $preLoginHookCommand;
  47. $this->userDisabledCheckCommand = $userDisabledCheckCommand;
  48. $this->uidLoginCommand = $uidLoginCommand;
  49. $this->emailLoginCommand = $emailLoginCommand;
  50. $this->loggedInCheckCommand = $loggedInCheckCommand;
  51. $this->completeLoginCommand = $completeLoginCommand;
  52. $this->createSessionTokenCommand = $createSessionTokenCommand;
  53. $this->clearLostPasswordTokensCommand = $clearLostPasswordTokensCommand;
  54. $this->updateLastPasswordConfirmCommand = $updateLastPasswordConfirmCommand;
  55. $this->setUserTimezoneCommand = $setUserTimezoneCommand;
  56. $this->twoFactorCommand = $twoFactorCommand;
  57. $this->finishRememberedLoginCommand = $finishRememberedLoginCommand;
  58. }
  59. public function process(LoginData $loginData): LoginResult {
  60. $chain = $this->preLoginHookCommand;
  61. $chain
  62. ->setNext($this->userDisabledCheckCommand)
  63. ->setNext($this->uidLoginCommand)
  64. ->setNext($this->emailLoginCommand)
  65. ->setNext($this->loggedInCheckCommand)
  66. ->setNext($this->completeLoginCommand)
  67. ->setNext($this->createSessionTokenCommand)
  68. ->setNext($this->clearLostPasswordTokensCommand)
  69. ->setNext($this->updateLastPasswordConfirmCommand)
  70. ->setNext($this->setUserTimezoneCommand)
  71. ->setNext($this->twoFactorCommand)
  72. ->setNext($this->finishRememberedLoginCommand);
  73. return $chain->process($loginData);
  74. }
  75. }