@@ -29,33 +29,33 @@ |
||
29 | 29 | |
30 | 30 | class EmailLoginCommand extends ALoginCommand { |
31 | 31 | |
32 | - /** @var IUserManager */ |
|
33 | - private $userManager; |
|
34 | - |
|
35 | - public function __construct(IUserManager $userManager) { |
|
36 | - $this->userManager = $userManager; |
|
37 | - } |
|
38 | - |
|
39 | - public function process(LoginData $loginData): LoginResult { |
|
40 | - if ($loginData->getUser() === false) { |
|
41 | - $users = $this->userManager->getByEmail($loginData->getUsername()); |
|
42 | - // we only allow login by email if unique |
|
43 | - if (count($users) === 1) { |
|
44 | - $username = $users[0]->getUID(); |
|
45 | - if ($username !== $loginData->getUsername()) { |
|
46 | - $user = $this->userManager->checkPassword( |
|
47 | - $username, |
|
48 | - $loginData->getPassword() |
|
49 | - ); |
|
50 | - if ($user !== false) { |
|
51 | - $loginData->setUser($user); |
|
52 | - $loginData->setUsername($username); |
|
53 | - } |
|
54 | - } |
|
55 | - } |
|
56 | - } |
|
57 | - |
|
58 | - return $this->processNextOrFinishSuccessfully($loginData); |
|
59 | - } |
|
32 | + /** @var IUserManager */ |
|
33 | + private $userManager; |
|
34 | + |
|
35 | + public function __construct(IUserManager $userManager) { |
|
36 | + $this->userManager = $userManager; |
|
37 | + } |
|
38 | + |
|
39 | + public function process(LoginData $loginData): LoginResult { |
|
40 | + if ($loginData->getUser() === false) { |
|
41 | + $users = $this->userManager->getByEmail($loginData->getUsername()); |
|
42 | + // we only allow login by email if unique |
|
43 | + if (count($users) === 1) { |
|
44 | + $username = $users[0]->getUID(); |
|
45 | + if ($username !== $loginData->getUsername()) { |
|
46 | + $user = $this->userManager->checkPassword( |
|
47 | + $username, |
|
48 | + $loginData->getPassword() |
|
49 | + ); |
|
50 | + if ($user !== false) { |
|
51 | + $loginData->setUser($user); |
|
52 | + $loginData->setUsername($username); |
|
53 | + } |
|
54 | + } |
|
55 | + } |
|
56 | + } |
|
57 | + |
|
58 | + return $this->processNextOrFinishSuccessfully($loginData); |
|
59 | + } |
|
60 | 60 | |
61 | 61 | } |
@@ -27,85 +27,85 @@ |
||
27 | 27 | |
28 | 28 | class Chain { |
29 | 29 | |
30 | - /** @var PreLoginHookCommand */ |
|
31 | - private $preLoginHookCommand; |
|
32 | - |
|
33 | - /** @var UserDisabledCheckCommand */ |
|
34 | - private $userDisabledCheckCommand; |
|
35 | - |
|
36 | - /** @var UidLoginCommand */ |
|
37 | - private $uidLoginCommand; |
|
38 | - |
|
39 | - /** @var EmailLoginCommand */ |
|
40 | - private $emailLoginCommand; |
|
41 | - |
|
42 | - /** @var LoggedInCheckCommand */ |
|
43 | - private $loggedInCheckCommand; |
|
44 | - |
|
45 | - /** @var CompleteLoginCommand */ |
|
46 | - private $completeLoginCommand; |
|
47 | - |
|
48 | - /** @var CreateSessionTokenCommand */ |
|
49 | - private $createSessionTokenCommand; |
|
50 | - |
|
51 | - /** @var ClearLostPasswordTokensCommand */ |
|
52 | - private $clearLostPasswordTokensCommand; |
|
53 | - |
|
54 | - /** @var UpdateLastPasswordConfirmCommand */ |
|
55 | - private $updateLastPasswordConfirmCommand; |
|
56 | - |
|
57 | - /** @var SetUserTimezoneCommand */ |
|
58 | - private $setUserTimezoneCommand; |
|
59 | - |
|
60 | - /** @var TwoFactorCommand */ |
|
61 | - private $twoFactorCommand; |
|
62 | - |
|
63 | - /** @var FinishRememberedLoginCommand */ |
|
64 | - private $finishRememberedLoginCommand; |
|
65 | - |
|
66 | - public function __construct(PreLoginHookCommand $preLoginHookCommand, |
|
67 | - UserDisabledCheckCommand $userDisabledCheckCommand, |
|
68 | - UidLoginCommand $uidLoginCommand, |
|
69 | - EmailLoginCommand $emailLoginCommand, |
|
70 | - LoggedInCheckCommand $loggedInCheckCommand, |
|
71 | - CompleteLoginCommand $completeLoginCommand, |
|
72 | - CreateSessionTokenCommand $createSessionTokenCommand, |
|
73 | - ClearLostPasswordTokensCommand $clearLostPasswordTokensCommand, |
|
74 | - UpdateLastPasswordConfirmCommand $updateLastPasswordConfirmCommand, |
|
75 | - SetUserTimezoneCommand $setUserTimezoneCommand, |
|
76 | - TwoFactorCommand $twoFactorCommand, |
|
77 | - FinishRememberedLoginCommand $finishRememberedLoginCommand |
|
78 | - ) { |
|
79 | - $this->preLoginHookCommand = $preLoginHookCommand; |
|
80 | - $this->userDisabledCheckCommand = $userDisabledCheckCommand; |
|
81 | - $this->uidLoginCommand = $uidLoginCommand; |
|
82 | - $this->emailLoginCommand = $emailLoginCommand; |
|
83 | - $this->loggedInCheckCommand = $loggedInCheckCommand; |
|
84 | - $this->completeLoginCommand = $completeLoginCommand; |
|
85 | - $this->createSessionTokenCommand = $createSessionTokenCommand; |
|
86 | - $this->clearLostPasswordTokensCommand = $clearLostPasswordTokensCommand; |
|
87 | - $this->updateLastPasswordConfirmCommand = $updateLastPasswordConfirmCommand; |
|
88 | - $this->setUserTimezoneCommand = $setUserTimezoneCommand; |
|
89 | - $this->twoFactorCommand = $twoFactorCommand; |
|
90 | - $this->finishRememberedLoginCommand = $finishRememberedLoginCommand; |
|
91 | - } |
|
92 | - |
|
93 | - public function process(LoginData $loginData): LoginResult { |
|
94 | - $chain = $this->preLoginHookCommand; |
|
95 | - $chain |
|
96 | - ->setNext($this->userDisabledCheckCommand) |
|
97 | - ->setNext($this->uidLoginCommand) |
|
98 | - ->setNext($this->emailLoginCommand) |
|
99 | - ->setNext($this->loggedInCheckCommand) |
|
100 | - ->setNext($this->completeLoginCommand) |
|
101 | - ->setNext($this->createSessionTokenCommand) |
|
102 | - ->setNext($this->clearLostPasswordTokensCommand) |
|
103 | - ->setNext($this->updateLastPasswordConfirmCommand) |
|
104 | - ->setNext($this->setUserTimezoneCommand) |
|
105 | - ->setNext($this->twoFactorCommand) |
|
106 | - ->setNext($this->finishRememberedLoginCommand); |
|
107 | - |
|
108 | - return $chain->process($loginData); |
|
109 | - } |
|
30 | + /** @var PreLoginHookCommand */ |
|
31 | + private $preLoginHookCommand; |
|
32 | + |
|
33 | + /** @var UserDisabledCheckCommand */ |
|
34 | + private $userDisabledCheckCommand; |
|
35 | + |
|
36 | + /** @var UidLoginCommand */ |
|
37 | + private $uidLoginCommand; |
|
38 | + |
|
39 | + /** @var EmailLoginCommand */ |
|
40 | + private $emailLoginCommand; |
|
41 | + |
|
42 | + /** @var LoggedInCheckCommand */ |
|
43 | + private $loggedInCheckCommand; |
|
44 | + |
|
45 | + /** @var CompleteLoginCommand */ |
|
46 | + private $completeLoginCommand; |
|
47 | + |
|
48 | + /** @var CreateSessionTokenCommand */ |
|
49 | + private $createSessionTokenCommand; |
|
50 | + |
|
51 | + /** @var ClearLostPasswordTokensCommand */ |
|
52 | + private $clearLostPasswordTokensCommand; |
|
53 | + |
|
54 | + /** @var UpdateLastPasswordConfirmCommand */ |
|
55 | + private $updateLastPasswordConfirmCommand; |
|
56 | + |
|
57 | + /** @var SetUserTimezoneCommand */ |
|
58 | + private $setUserTimezoneCommand; |
|
59 | + |
|
60 | + /** @var TwoFactorCommand */ |
|
61 | + private $twoFactorCommand; |
|
62 | + |
|
63 | + /** @var FinishRememberedLoginCommand */ |
|
64 | + private $finishRememberedLoginCommand; |
|
65 | + |
|
66 | + public function __construct(PreLoginHookCommand $preLoginHookCommand, |
|
67 | + UserDisabledCheckCommand $userDisabledCheckCommand, |
|
68 | + UidLoginCommand $uidLoginCommand, |
|
69 | + EmailLoginCommand $emailLoginCommand, |
|
70 | + LoggedInCheckCommand $loggedInCheckCommand, |
|
71 | + CompleteLoginCommand $completeLoginCommand, |
|
72 | + CreateSessionTokenCommand $createSessionTokenCommand, |
|
73 | + ClearLostPasswordTokensCommand $clearLostPasswordTokensCommand, |
|
74 | + UpdateLastPasswordConfirmCommand $updateLastPasswordConfirmCommand, |
|
75 | + SetUserTimezoneCommand $setUserTimezoneCommand, |
|
76 | + TwoFactorCommand $twoFactorCommand, |
|
77 | + FinishRememberedLoginCommand $finishRememberedLoginCommand |
|
78 | + ) { |
|
79 | + $this->preLoginHookCommand = $preLoginHookCommand; |
|
80 | + $this->userDisabledCheckCommand = $userDisabledCheckCommand; |
|
81 | + $this->uidLoginCommand = $uidLoginCommand; |
|
82 | + $this->emailLoginCommand = $emailLoginCommand; |
|
83 | + $this->loggedInCheckCommand = $loggedInCheckCommand; |
|
84 | + $this->completeLoginCommand = $completeLoginCommand; |
|
85 | + $this->createSessionTokenCommand = $createSessionTokenCommand; |
|
86 | + $this->clearLostPasswordTokensCommand = $clearLostPasswordTokensCommand; |
|
87 | + $this->updateLastPasswordConfirmCommand = $updateLastPasswordConfirmCommand; |
|
88 | + $this->setUserTimezoneCommand = $setUserTimezoneCommand; |
|
89 | + $this->twoFactorCommand = $twoFactorCommand; |
|
90 | + $this->finishRememberedLoginCommand = $finishRememberedLoginCommand; |
|
91 | + } |
|
92 | + |
|
93 | + public function process(LoginData $loginData): LoginResult { |
|
94 | + $chain = $this->preLoginHookCommand; |
|
95 | + $chain |
|
96 | + ->setNext($this->userDisabledCheckCommand) |
|
97 | + ->setNext($this->uidLoginCommand) |
|
98 | + ->setNext($this->emailLoginCommand) |
|
99 | + ->setNext($this->loggedInCheckCommand) |
|
100 | + ->setNext($this->completeLoginCommand) |
|
101 | + ->setNext($this->createSessionTokenCommand) |
|
102 | + ->setNext($this->clearLostPasswordTokensCommand) |
|
103 | + ->setNext($this->updateLastPasswordConfirmCommand) |
|
104 | + ->setNext($this->setUserTimezoneCommand) |
|
105 | + ->setNext($this->twoFactorCommand) |
|
106 | + ->setNext($this->finishRememberedLoginCommand); |
|
107 | + |
|
108 | + return $chain->process($loginData); |
|
109 | + } |
|
110 | 110 | |
111 | 111 | } |
@@ -30,33 +30,33 @@ |
||
30 | 30 | |
31 | 31 | class SetUserTimezoneCommand extends ALoginCommand { |
32 | 32 | |
33 | - /** @var IConfig */ |
|
34 | - private $config; |
|
35 | - |
|
36 | - /** @var ISession */ |
|
37 | - private $session; |
|
38 | - |
|
39 | - public function __construct(IConfig $config, |
|
40 | - ISession $session) { |
|
41 | - $this->config = $config; |
|
42 | - $this->session = $session; |
|
43 | - } |
|
44 | - |
|
45 | - public function process(LoginData $loginData): LoginResult { |
|
46 | - if ($loginData->getTimeZoneOffset() !== '') { |
|
47 | - $this->config->setUserValue( |
|
48 | - $loginData->getUser()->getUID(), |
|
49 | - 'core', |
|
50 | - 'timezone', |
|
51 | - $loginData->getTimeZone() |
|
52 | - ); |
|
53 | - $this->session->set( |
|
54 | - 'timezone', |
|
55 | - $loginData->getTimeZoneOffset() |
|
56 | - ); |
|
57 | - } |
|
58 | - |
|
59 | - return $this->processNextOrFinishSuccessfully($loginData); |
|
60 | - } |
|
33 | + /** @var IConfig */ |
|
34 | + private $config; |
|
35 | + |
|
36 | + /** @var ISession */ |
|
37 | + private $session; |
|
38 | + |
|
39 | + public function __construct(IConfig $config, |
|
40 | + ISession $session) { |
|
41 | + $this->config = $config; |
|
42 | + $this->session = $session; |
|
43 | + } |
|
44 | + |
|
45 | + public function process(LoginData $loginData): LoginResult { |
|
46 | + if ($loginData->getTimeZoneOffset() !== '') { |
|
47 | + $this->config->setUserValue( |
|
48 | + $loginData->getUser()->getUID(), |
|
49 | + 'core', |
|
50 | + 'timezone', |
|
51 | + $loginData->getTimeZone() |
|
52 | + ); |
|
53 | + $this->session->set( |
|
54 | + 'timezone', |
|
55 | + $loginData->getTimeZoneOffset() |
|
56 | + ); |
|
57 | + } |
|
58 | + |
|
59 | + return $this->processNextOrFinishSuccessfully($loginData); |
|
60 | + } |
|
61 | 61 | |
62 | 62 | } |
@@ -30,14 +30,14 @@ |
||
30 | 30 | */ |
31 | 31 | interface IMessageReporter extends IReporter { |
32 | 32 | |
33 | - /** |
|
34 | - * Report a (error) message |
|
35 | - * |
|
36 | - * @param string $message |
|
37 | - * @param array $context |
|
38 | - * |
|
39 | - * @since 17.0.0 |
|
40 | - */ |
|
41 | - public function reportMessage(string $message, array $context = []): void; |
|
33 | + /** |
|
34 | + * Report a (error) message |
|
35 | + * |
|
36 | + * @param string $message |
|
37 | + * @param array $context |
|
38 | + * |
|
39 | + * @since 17.0.0 |
|
40 | + */ |
|
41 | + public function reportMessage(string $message, array $context = []): void; |
|
42 | 42 | |
43 | 43 | } |
@@ -28,10 +28,10 @@ |
||
28 | 28 | */ |
29 | 29 | interface ISupportedApps extends ISubscription { |
30 | 30 | |
31 | - /** |
|
32 | - * Fetches the list of app IDs that are supported by the subscription |
|
33 | - * |
|
34 | - * @since 17.0.0 |
|
35 | - */ |
|
36 | - public function getSupportedApps(): array; |
|
31 | + /** |
|
32 | + * Fetches the list of app IDs that are supported by the subscription |
|
33 | + * |
|
34 | + * @since 17.0.0 |
|
35 | + */ |
|
36 | + public function getSupportedApps(): array; |
|
37 | 37 | } |
@@ -31,13 +31,13 @@ |
||
31 | 31 | */ |
32 | 32 | interface IActivatableAtLogin extends IProvider { |
33 | 33 | |
34 | - /** |
|
35 | - * @param IUser $user |
|
36 | - * |
|
37 | - * @return ILoginSetupProvider |
|
38 | - * |
|
39 | - * @since 17.0.0 |
|
40 | - */ |
|
41 | - public function getLoginSetup(IUser $user): ILoginSetupProvider; |
|
34 | + /** |
|
35 | + * @param IUser $user |
|
36 | + * |
|
37 | + * @return ILoginSetupProvider |
|
38 | + * |
|
39 | + * @since 17.0.0 |
|
40 | + */ |
|
41 | + public function getLoginSetup(IUser $user): ILoginSetupProvider; |
|
42 | 42 | |
43 | 43 | } |
@@ -31,11 +31,11 @@ |
||
31 | 31 | */ |
32 | 32 | interface ILoginSetupProvider { |
33 | 33 | |
34 | - /** |
|
35 | - * @return Template |
|
36 | - * |
|
37 | - * @since 17.0.0 |
|
38 | - */ |
|
39 | - public function getBody(): Template; |
|
34 | + /** |
|
35 | + * @return Template |
|
36 | + * |
|
37 | + * @since 17.0.0 |
|
38 | + */ |
|
39 | + public function getBody(): Template; |
|
40 | 40 | |
41 | 41 | } |
@@ -26,16 +26,16 @@ |
||
26 | 26 | use OC\Authentication\Token\IToken; |
27 | 27 | |
28 | 28 | class WipeTokenException extends InvalidTokenException { |
29 | - /** @var IToken */ |
|
30 | - private $token; |
|
29 | + /** @var IToken */ |
|
30 | + private $token; |
|
31 | 31 | |
32 | - public function __construct(IToken $token) { |
|
33 | - parent::__construct(); |
|
32 | + public function __construct(IToken $token) { |
|
33 | + parent::__construct(); |
|
34 | 34 | |
35 | - $this->token = $token; |
|
36 | - } |
|
35 | + $this->token = $token; |
|
36 | + } |
|
37 | 37 | |
38 | - public function getToken(): IToken { |
|
39 | - return $this->token; |
|
40 | - } |
|
38 | + public function getToken(): IToken { |
|
39 | + return $this->token; |
|
40 | + } |
|
41 | 41 | } |
@@ -35,64 +35,64 @@ |
||
35 | 35 | |
36 | 36 | class WipeController extends Controller { |
37 | 37 | |
38 | - /** @var RemoteWipe */ |
|
39 | - private $remoteWipe; |
|
38 | + /** @var RemoteWipe */ |
|
39 | + private $remoteWipe; |
|
40 | 40 | |
41 | - public function __construct(string $appName, |
|
42 | - IRequest $request, |
|
43 | - RemoteWipe $remoteWipe) { |
|
44 | - parent::__construct($appName, $request); |
|
41 | + public function __construct(string $appName, |
|
42 | + IRequest $request, |
|
43 | + RemoteWipe $remoteWipe) { |
|
44 | + parent::__construct($appName, $request); |
|
45 | 45 | |
46 | - $this->remoteWipe = $remoteWipe; |
|
47 | - } |
|
46 | + $this->remoteWipe = $remoteWipe; |
|
47 | + } |
|
48 | 48 | |
49 | - /** |
|
50 | - * @NoAdminRequired |
|
51 | - * @NoCSRFRequired |
|
52 | - * @PublicPage |
|
53 | - * |
|
54 | - * @AnonRateThrottle(limit=10, period=300) |
|
55 | - * |
|
56 | - * @param string $token |
|
57 | - * |
|
58 | - * @return JSONResponse |
|
59 | - */ |
|
60 | - public function checkWipe(string $token): JSONResponse { |
|
61 | - try { |
|
62 | - if ($this->remoteWipe->start($token)) { |
|
63 | - return new JSONResponse([ |
|
64 | - 'wipe' => true |
|
65 | - ]); |
|
66 | - } |
|
49 | + /** |
|
50 | + * @NoAdminRequired |
|
51 | + * @NoCSRFRequired |
|
52 | + * @PublicPage |
|
53 | + * |
|
54 | + * @AnonRateThrottle(limit=10, period=300) |
|
55 | + * |
|
56 | + * @param string $token |
|
57 | + * |
|
58 | + * @return JSONResponse |
|
59 | + */ |
|
60 | + public function checkWipe(string $token): JSONResponse { |
|
61 | + try { |
|
62 | + if ($this->remoteWipe->start($token)) { |
|
63 | + return new JSONResponse([ |
|
64 | + 'wipe' => true |
|
65 | + ]); |
|
66 | + } |
|
67 | 67 | |
68 | - return new JSONResponse([], Http::STATUS_NOT_FOUND); |
|
69 | - } catch (InvalidTokenException $e) { |
|
70 | - return new JSONResponse([], Http::STATUS_NOT_FOUND); |
|
71 | - } |
|
72 | - } |
|
68 | + return new JSONResponse([], Http::STATUS_NOT_FOUND); |
|
69 | + } catch (InvalidTokenException $e) { |
|
70 | + return new JSONResponse([], Http::STATUS_NOT_FOUND); |
|
71 | + } |
|
72 | + } |
|
73 | 73 | |
74 | 74 | |
75 | - /** |
|
76 | - * @NoAdminRequired |
|
77 | - * @NoCSRFRequired |
|
78 | - * @PublicPage |
|
79 | - * |
|
80 | - * @AnonRateThrottle(limit=10, period=300) |
|
81 | - * |
|
82 | - * @param string $token |
|
83 | - * |
|
84 | - * @return JSONResponse |
|
85 | - */ |
|
86 | - public function wipeDone(string $token): JSONResponse { |
|
87 | - try { |
|
88 | - if ($this->remoteWipe->finish($token)) { |
|
89 | - return new JSONResponse([]); |
|
90 | - } |
|
75 | + /** |
|
76 | + * @NoAdminRequired |
|
77 | + * @NoCSRFRequired |
|
78 | + * @PublicPage |
|
79 | + * |
|
80 | + * @AnonRateThrottle(limit=10, period=300) |
|
81 | + * |
|
82 | + * @param string $token |
|
83 | + * |
|
84 | + * @return JSONResponse |
|
85 | + */ |
|
86 | + public function wipeDone(string $token): JSONResponse { |
|
87 | + try { |
|
88 | + if ($this->remoteWipe->finish($token)) { |
|
89 | + return new JSONResponse([]); |
|
90 | + } |
|
91 | 91 | |
92 | - return new JSONResponse([], Http::STATUS_NOT_FOUND); |
|
93 | - } catch (InvalidTokenException $e) { |
|
94 | - return new JSONResponse([], Http::STATUS_NOT_FOUND); |
|
95 | - } |
|
96 | - } |
|
92 | + return new JSONResponse([], Http::STATUS_NOT_FOUND); |
|
93 | + } catch (InvalidTokenException $e) { |
|
94 | + return new JSONResponse([], Http::STATUS_NOT_FOUND); |
|
95 | + } |
|
96 | + } |
|
97 | 97 | |
98 | 98 | } |