@@ -32,119 +32,119 @@ |
||
32 | 32 | * @since 16.0.0 |
33 | 33 | */ |
34 | 34 | class InMemoryFile implements ISimpleFile { |
35 | - /** |
|
36 | - * Holds the file name. |
|
37 | - * |
|
38 | - * @var string |
|
39 | - */ |
|
40 | - private $name; |
|
41 | - |
|
42 | - /** |
|
43 | - * Holds the file contents. |
|
44 | - * |
|
45 | - * @var string |
|
46 | - */ |
|
47 | - private $contents; |
|
48 | - |
|
49 | - /** |
|
50 | - * InMemoryFile constructor. |
|
51 | - * |
|
52 | - * @param string $name The file name |
|
53 | - * @param string $contents The file contents |
|
54 | - * @since 16.0.0 |
|
55 | - */ |
|
56 | - public function __construct(string $name, string $contents) { |
|
57 | - $this->name = $name; |
|
58 | - $this->contents = $contents; |
|
59 | - } |
|
60 | - |
|
61 | - /** |
|
62 | - * @inheritdoc |
|
63 | - * @since 16.0.0 |
|
64 | - */ |
|
65 | - public function getName() { |
|
66 | - return $this->name; |
|
67 | - } |
|
68 | - |
|
69 | - /** |
|
70 | - * @inheritdoc |
|
71 | - * @since 16.0.0 |
|
72 | - */ |
|
73 | - public function getSize() { |
|
74 | - return strlen($this->contents); |
|
75 | - } |
|
76 | - |
|
77 | - /** |
|
78 | - * @inheritdoc |
|
79 | - * @since 16.0.0 |
|
80 | - */ |
|
81 | - public function getETag() { |
|
82 | - return ''; |
|
83 | - } |
|
84 | - |
|
85 | - /** |
|
86 | - * @inheritdoc |
|
87 | - * @since 16.0.0 |
|
88 | - */ |
|
89 | - public function getMTime() { |
|
90 | - return time(); |
|
91 | - } |
|
92 | - |
|
93 | - /** |
|
94 | - * @inheritdoc |
|
95 | - * @since 16.0.0 |
|
96 | - */ |
|
97 | - public function getContent() { |
|
98 | - return $this->contents; |
|
99 | - } |
|
100 | - |
|
101 | - /** |
|
102 | - * @inheritdoc |
|
103 | - * @since 16.0.0 |
|
104 | - */ |
|
105 | - public function putContent($data) { |
|
106 | - $this->contents = $data; |
|
107 | - } |
|
108 | - |
|
109 | - /** |
|
110 | - * In memory files can't be deleted. |
|
111 | - * |
|
112 | - * @since 16.0.0 |
|
113 | - */ |
|
114 | - public function delete() { |
|
115 | - // unimplemented for in memory files |
|
116 | - } |
|
117 | - |
|
118 | - /** |
|
119 | - * @inheritdoc |
|
120 | - * @since 16.0.0 |
|
121 | - */ |
|
122 | - public function getMimeType() { |
|
123 | - $fileInfo = new \finfo(FILEINFO_MIME_TYPE); |
|
124 | - return $fileInfo->buffer($this->contents); |
|
125 | - } |
|
126 | - |
|
127 | - /** |
|
128 | - * Stream reading is unsupported for in memory files. |
|
129 | - * |
|
130 | - * @throws NotPermittedException |
|
131 | - * @since 16.0.0 |
|
132 | - */ |
|
133 | - public function read() { |
|
134 | - throw new NotPermittedException( |
|
135 | - 'Stream reading is unsupported for in memory files' |
|
136 | - ); |
|
137 | - } |
|
138 | - |
|
139 | - /** |
|
140 | - * Stream writing isn't available for in memory files. |
|
141 | - * |
|
142 | - * @throws NotPermittedException |
|
143 | - * @since 16.0.0 |
|
144 | - */ |
|
145 | - public function write() { |
|
146 | - throw new NotPermittedException( |
|
147 | - 'Stream writing is unsupported for in memory files' |
|
148 | - ); |
|
149 | - } |
|
35 | + /** |
|
36 | + * Holds the file name. |
|
37 | + * |
|
38 | + * @var string |
|
39 | + */ |
|
40 | + private $name; |
|
41 | + |
|
42 | + /** |
|
43 | + * Holds the file contents. |
|
44 | + * |
|
45 | + * @var string |
|
46 | + */ |
|
47 | + private $contents; |
|
48 | + |
|
49 | + /** |
|
50 | + * InMemoryFile constructor. |
|
51 | + * |
|
52 | + * @param string $name The file name |
|
53 | + * @param string $contents The file contents |
|
54 | + * @since 16.0.0 |
|
55 | + */ |
|
56 | + public function __construct(string $name, string $contents) { |
|
57 | + $this->name = $name; |
|
58 | + $this->contents = $contents; |
|
59 | + } |
|
60 | + |
|
61 | + /** |
|
62 | + * @inheritdoc |
|
63 | + * @since 16.0.0 |
|
64 | + */ |
|
65 | + public function getName() { |
|
66 | + return $this->name; |
|
67 | + } |
|
68 | + |
|
69 | + /** |
|
70 | + * @inheritdoc |
|
71 | + * @since 16.0.0 |
|
72 | + */ |
|
73 | + public function getSize() { |
|
74 | + return strlen($this->contents); |
|
75 | + } |
|
76 | + |
|
77 | + /** |
|
78 | + * @inheritdoc |
|
79 | + * @since 16.0.0 |
|
80 | + */ |
|
81 | + public function getETag() { |
|
82 | + return ''; |
|
83 | + } |
|
84 | + |
|
85 | + /** |
|
86 | + * @inheritdoc |
|
87 | + * @since 16.0.0 |
|
88 | + */ |
|
89 | + public function getMTime() { |
|
90 | + return time(); |
|
91 | + } |
|
92 | + |
|
93 | + /** |
|
94 | + * @inheritdoc |
|
95 | + * @since 16.0.0 |
|
96 | + */ |
|
97 | + public function getContent() { |
|
98 | + return $this->contents; |
|
99 | + } |
|
100 | + |
|
101 | + /** |
|
102 | + * @inheritdoc |
|
103 | + * @since 16.0.0 |
|
104 | + */ |
|
105 | + public function putContent($data) { |
|
106 | + $this->contents = $data; |
|
107 | + } |
|
108 | + |
|
109 | + /** |
|
110 | + * In memory files can't be deleted. |
|
111 | + * |
|
112 | + * @since 16.0.0 |
|
113 | + */ |
|
114 | + public function delete() { |
|
115 | + // unimplemented for in memory files |
|
116 | + } |
|
117 | + |
|
118 | + /** |
|
119 | + * @inheritdoc |
|
120 | + * @since 16.0.0 |
|
121 | + */ |
|
122 | + public function getMimeType() { |
|
123 | + $fileInfo = new \finfo(FILEINFO_MIME_TYPE); |
|
124 | + return $fileInfo->buffer($this->contents); |
|
125 | + } |
|
126 | + |
|
127 | + /** |
|
128 | + * Stream reading is unsupported for in memory files. |
|
129 | + * |
|
130 | + * @throws NotPermittedException |
|
131 | + * @since 16.0.0 |
|
132 | + */ |
|
133 | + public function read() { |
|
134 | + throw new NotPermittedException( |
|
135 | + 'Stream reading is unsupported for in memory files' |
|
136 | + ); |
|
137 | + } |
|
138 | + |
|
139 | + /** |
|
140 | + * Stream writing isn't available for in memory files. |
|
141 | + * |
|
142 | + * @throws NotPermittedException |
|
143 | + * @since 16.0.0 |
|
144 | + */ |
|
145 | + public function write() { |
|
146 | + throw new NotPermittedException( |
|
147 | + 'Stream writing is unsupported for in memory files' |
|
148 | + ); |
|
149 | + } |
|
150 | 150 | } |
@@ -34,24 +34,24 @@ |
||
34 | 34 | |
35 | 35 | interface IAvatarManager { |
36 | 36 | |
37 | - /** |
|
38 | - * return a user specific instance of \OCP\IAvatar |
|
39 | - * @see IAvatar |
|
40 | - * @param string $user the ownCloud user id |
|
41 | - * @return IAvatar |
|
42 | - * @throws \Exception In case the username is potentially dangerous |
|
43 | - * @throws \OCP\Files\NotFoundException In case there is no user folder yet |
|
44 | - * @since 6.0.0 |
|
45 | - */ |
|
46 | - public function getAvatar(string $user) : IAvatar; |
|
37 | + /** |
|
38 | + * return a user specific instance of \OCP\IAvatar |
|
39 | + * @see IAvatar |
|
40 | + * @param string $user the ownCloud user id |
|
41 | + * @return IAvatar |
|
42 | + * @throws \Exception In case the username is potentially dangerous |
|
43 | + * @throws \OCP\Files\NotFoundException In case there is no user folder yet |
|
44 | + * @since 6.0.0 |
|
45 | + */ |
|
46 | + public function getAvatar(string $user) : IAvatar; |
|
47 | 47 | |
48 | - /** |
|
49 | - * Returns a guest user avatar instance. |
|
50 | - * |
|
51 | - * @param string $name The guest name, e.g. "Albert". |
|
52 | - * @return IAvatar |
|
53 | - * @since 16.0.0 |
|
54 | - */ |
|
55 | - public function getGuestAvatar(string $name): IAvatar; |
|
48 | + /** |
|
49 | + * Returns a guest user avatar instance. |
|
50 | + * |
|
51 | + * @param string $name The guest name, e.g. "Albert". |
|
52 | + * @return IAvatar |
|
53 | + * @since 16.0.0 |
|
54 | + */ |
|
55 | + public function getGuestAvatar(string $name): IAvatar; |
|
56 | 56 | |
57 | 57 | } |
@@ -30,10 +30,10 @@ |
||
30 | 30 | * @since 16.0.0 |
31 | 31 | */ |
32 | 32 | interface IConfigHandler { |
33 | - /** |
|
34 | - * @param mixed $optionValue |
|
35 | - * @return mixed the same type as $optionValue |
|
36 | - * @since 16.0.0 |
|
37 | - */ |
|
38 | - public function handle($optionValue); |
|
33 | + /** |
|
34 | + * @param mixed $optionValue |
|
35 | + * @return mixed the same type as $optionValue |
|
36 | + * @since 16.0.0 |
|
37 | + */ |
|
38 | + public function handle($optionValue); |
|
39 | 39 | } |
@@ -28,47 +28,47 @@ |
||
28 | 28 | |
29 | 29 | class GenerateBirthdayCalendarBackgroundJob extends QueuedJob { |
30 | 30 | |
31 | - /** @var BirthdayService */ |
|
32 | - private $birthdayService; |
|
31 | + /** @var BirthdayService */ |
|
32 | + private $birthdayService; |
|
33 | 33 | |
34 | - /** @var IConfig */ |
|
35 | - private $config; |
|
34 | + /** @var IConfig */ |
|
35 | + private $config; |
|
36 | 36 | |
37 | - /** |
|
38 | - * GenerateAllBirthdayCalendarsBackgroundJob constructor. |
|
39 | - * |
|
40 | - * @param BirthdayService $birthdayService |
|
41 | - * @param IConfig $config |
|
42 | - */ |
|
43 | - public function __construct(BirthdayService $birthdayService, |
|
44 | - IConfig $config) { |
|
45 | - $this->birthdayService = $birthdayService; |
|
46 | - $this->config = $config; |
|
47 | - } |
|
37 | + /** |
|
38 | + * GenerateAllBirthdayCalendarsBackgroundJob constructor. |
|
39 | + * |
|
40 | + * @param BirthdayService $birthdayService |
|
41 | + * @param IConfig $config |
|
42 | + */ |
|
43 | + public function __construct(BirthdayService $birthdayService, |
|
44 | + IConfig $config) { |
|
45 | + $this->birthdayService = $birthdayService; |
|
46 | + $this->config = $config; |
|
47 | + } |
|
48 | 48 | |
49 | - /** |
|
50 | - * @param array $arguments |
|
51 | - */ |
|
52 | - public function run($arguments) { |
|
53 | - $userId = $arguments['userId']; |
|
54 | - $purgeBeforeGenerating = $arguments['purgeBeforeGenerating'] ?? false; |
|
49 | + /** |
|
50 | + * @param array $arguments |
|
51 | + */ |
|
52 | + public function run($arguments) { |
|
53 | + $userId = $arguments['userId']; |
|
54 | + $purgeBeforeGenerating = $arguments['purgeBeforeGenerating'] ?? false; |
|
55 | 55 | |
56 | - // make sure admin didn't change his mind |
|
57 | - $isGloballyEnabled = $this->config->getAppValue('dav', 'generateBirthdayCalendar', 'yes'); |
|
58 | - if ($isGloballyEnabled !== 'yes') { |
|
59 | - return; |
|
60 | - } |
|
56 | + // make sure admin didn't change his mind |
|
57 | + $isGloballyEnabled = $this->config->getAppValue('dav', 'generateBirthdayCalendar', 'yes'); |
|
58 | + if ($isGloballyEnabled !== 'yes') { |
|
59 | + return; |
|
60 | + } |
|
61 | 61 | |
62 | - // did the user opt out? |
|
63 | - $isUserEnabled = $this->config->getUserValue($userId, 'dav', 'generateBirthdayCalendar', 'yes'); |
|
64 | - if ($isUserEnabled !== 'yes') { |
|
65 | - return; |
|
66 | - } |
|
62 | + // did the user opt out? |
|
63 | + $isUserEnabled = $this->config->getUserValue($userId, 'dav', 'generateBirthdayCalendar', 'yes'); |
|
64 | + if ($isUserEnabled !== 'yes') { |
|
65 | + return; |
|
66 | + } |
|
67 | 67 | |
68 | - if ($purgeBeforeGenerating) { |
|
69 | - $this->birthdayService->resetForUser($userId); |
|
70 | - } |
|
68 | + if ($purgeBeforeGenerating) { |
|
69 | + $this->birthdayService->resetForUser($userId); |
|
70 | + } |
|
71 | 71 | |
72 | - $this->birthdayService->syncUser($userId); |
|
73 | - } |
|
72 | + $this->birthdayService->syncUser($userId); |
|
73 | + } |
|
74 | 74 | } |
@@ -28,38 +28,38 @@ |
||
28 | 28 | |
29 | 29 | class Capabilities implements ICapability { |
30 | 30 | |
31 | - /** @var IURLGenerator */ |
|
32 | - private $urlGenerator; |
|
31 | + /** @var IURLGenerator */ |
|
32 | + private $urlGenerator; |
|
33 | 33 | |
34 | - public function __construct(IURLGenerator $urlGenerator) { |
|
35 | - $this->urlGenerator = $urlGenerator; |
|
36 | - } |
|
34 | + public function __construct(IURLGenerator $urlGenerator) { |
|
35 | + $this->urlGenerator = $urlGenerator; |
|
36 | + } |
|
37 | 37 | |
38 | - /** |
|
39 | - * Function an app uses to return the capabilities |
|
40 | - * |
|
41 | - * @return array Array containing the apps capabilities |
|
42 | - * @since 8.2.0 |
|
43 | - */ |
|
44 | - public function getCapabilities() { |
|
45 | - $url = $this->urlGenerator->linkToRouteAbsolute('cloud_federation_api.requesthandlercontroller.addShare'); |
|
46 | - $capabilities = ['ocm' => |
|
47 | - [ |
|
48 | - 'enabled' => true, |
|
49 | - 'apiVersion' => '1.0-proposal1', |
|
50 | - 'endPoint' => substr($url, 0, strrpos($url, '/')), |
|
51 | - 'resourceTypes' => [ |
|
52 | - [ |
|
53 | - 'name' => 'file', |
|
54 | - 'shareTypes' => ['user', 'group'], |
|
55 | - 'protocols' => [ |
|
56 | - 'webdav' => '/public.php/webdav/', |
|
57 | - ] |
|
58 | - ], |
|
59 | - ] |
|
60 | - ] |
|
61 | - ]; |
|
38 | + /** |
|
39 | + * Function an app uses to return the capabilities |
|
40 | + * |
|
41 | + * @return array Array containing the apps capabilities |
|
42 | + * @since 8.2.0 |
|
43 | + */ |
|
44 | + public function getCapabilities() { |
|
45 | + $url = $this->urlGenerator->linkToRouteAbsolute('cloud_federation_api.requesthandlercontroller.addShare'); |
|
46 | + $capabilities = ['ocm' => |
|
47 | + [ |
|
48 | + 'enabled' => true, |
|
49 | + 'apiVersion' => '1.0-proposal1', |
|
50 | + 'endPoint' => substr($url, 0, strrpos($url, '/')), |
|
51 | + 'resourceTypes' => [ |
|
52 | + [ |
|
53 | + 'name' => 'file', |
|
54 | + 'shareTypes' => ['user', 'group'], |
|
55 | + 'protocols' => [ |
|
56 | + 'webdav' => '/public.php/webdav/', |
|
57 | + ] |
|
58 | + ], |
|
59 | + ] |
|
60 | + ] |
|
61 | + ]; |
|
62 | 62 | |
63 | - return $capabilities; |
|
64 | - } |
|
63 | + return $capabilities; |
|
64 | + } |
|
65 | 65 | } |
@@ -31,19 +31,19 @@ |
||
31 | 31 | |
32 | 32 | class AddClenupLoginFlowV2BackgroundJob implements IRepairStep { |
33 | 33 | |
34 | - /** @var IJobList */ |
|
35 | - private $jobList; |
|
34 | + /** @var IJobList */ |
|
35 | + private $jobList; |
|
36 | 36 | |
37 | - public function __construct(IJobList $jobList) { |
|
38 | - $this->jobList = $jobList; |
|
39 | - } |
|
37 | + public function __construct(IJobList $jobList) { |
|
38 | + $this->jobList = $jobList; |
|
39 | + } |
|
40 | 40 | |
41 | - public function getName(): string { |
|
42 | - return 'Add background job to cleanup login flow v2 tokens'; |
|
43 | - } |
|
41 | + public function getName(): string { |
|
42 | + return 'Add background job to cleanup login flow v2 tokens'; |
|
43 | + } |
|
44 | 44 | |
45 | - public function run(IOutput $output) { |
|
46 | - $this->jobList->add(CleanupLoginFlowV2::class); |
|
47 | - } |
|
45 | + public function run(IOutput $output) { |
|
46 | + $this->jobList->add(CleanupLoginFlowV2::class); |
|
47 | + } |
|
48 | 48 | |
49 | 49 | } |
@@ -25,47 +25,47 @@ |
||
25 | 25 | namespace OC\Core\Data; |
26 | 26 | |
27 | 27 | class LoginFlowV2Credentials implements \JsonSerializable { |
28 | - /** @var string */ |
|
29 | - private $server; |
|
30 | - /** @var string */ |
|
31 | - private $loginName; |
|
32 | - /** @var string */ |
|
33 | - private $appPassword; |
|
28 | + /** @var string */ |
|
29 | + private $server; |
|
30 | + /** @var string */ |
|
31 | + private $loginName; |
|
32 | + /** @var string */ |
|
33 | + private $appPassword; |
|
34 | 34 | |
35 | - public function __construct(string $server, string $loginName, string $appPassword) { |
|
36 | - $this->server = $server; |
|
37 | - $this->loginName = $loginName; |
|
38 | - $this->appPassword = $appPassword; |
|
39 | - } |
|
35 | + public function __construct(string $server, string $loginName, string $appPassword) { |
|
36 | + $this->server = $server; |
|
37 | + $this->loginName = $loginName; |
|
38 | + $this->appPassword = $appPassword; |
|
39 | + } |
|
40 | 40 | |
41 | - /** |
|
42 | - * @return string |
|
43 | - */ |
|
44 | - public function getServer(): string { |
|
45 | - return $this->server; |
|
46 | - } |
|
41 | + /** |
|
42 | + * @return string |
|
43 | + */ |
|
44 | + public function getServer(): string { |
|
45 | + return $this->server; |
|
46 | + } |
|
47 | 47 | |
48 | - /** |
|
49 | - * @return string |
|
50 | - */ |
|
51 | - public function getLoginName(): string { |
|
52 | - return $this->loginName; |
|
53 | - } |
|
48 | + /** |
|
49 | + * @return string |
|
50 | + */ |
|
51 | + public function getLoginName(): string { |
|
52 | + return $this->loginName; |
|
53 | + } |
|
54 | 54 | |
55 | - /** |
|
56 | - * @return string |
|
57 | - */ |
|
58 | - public function getAppPassword(): string { |
|
59 | - return $this->appPassword; |
|
60 | - } |
|
55 | + /** |
|
56 | + * @return string |
|
57 | + */ |
|
58 | + public function getAppPassword(): string { |
|
59 | + return $this->appPassword; |
|
60 | + } |
|
61 | 61 | |
62 | - public function jsonSerialize(): array { |
|
63 | - return [ |
|
64 | - 'server' => $this->server, |
|
65 | - 'loginName' => $this->loginName, |
|
66 | - 'appPassword' => $this->appPassword, |
|
67 | - ]; |
|
68 | - } |
|
62 | + public function jsonSerialize(): array { |
|
63 | + return [ |
|
64 | + 'server' => $this->server, |
|
65 | + 'loginName' => $this->loginName, |
|
66 | + 'appPassword' => $this->appPassword, |
|
67 | + ]; |
|
68 | + } |
|
69 | 69 | |
70 | 70 | |
71 | 71 | } |
@@ -49,37 +49,37 @@ |
||
49 | 49 | * @method void setAppPassword(string $appPassword) |
50 | 50 | */ |
51 | 51 | class LoginFlowV2 extends Entity { |
52 | - /** @var int */ |
|
53 | - protected $timestamp; |
|
54 | - /** @var int */ |
|
55 | - protected $started; |
|
56 | - /** @var string */ |
|
57 | - protected $pollToken; |
|
58 | - /** @var string */ |
|
59 | - protected $loginToken; |
|
60 | - /** @var string */ |
|
61 | - protected $publicKey; |
|
62 | - /** @var string */ |
|
63 | - protected $privateKey; |
|
64 | - /** @var string */ |
|
65 | - protected $clientName; |
|
66 | - /** @var string */ |
|
67 | - protected $loginName; |
|
68 | - /** @var string */ |
|
69 | - protected $server; |
|
70 | - /** @var string */ |
|
71 | - protected $appPassword; |
|
52 | + /** @var int */ |
|
53 | + protected $timestamp; |
|
54 | + /** @var int */ |
|
55 | + protected $started; |
|
56 | + /** @var string */ |
|
57 | + protected $pollToken; |
|
58 | + /** @var string */ |
|
59 | + protected $loginToken; |
|
60 | + /** @var string */ |
|
61 | + protected $publicKey; |
|
62 | + /** @var string */ |
|
63 | + protected $privateKey; |
|
64 | + /** @var string */ |
|
65 | + protected $clientName; |
|
66 | + /** @var string */ |
|
67 | + protected $loginName; |
|
68 | + /** @var string */ |
|
69 | + protected $server; |
|
70 | + /** @var string */ |
|
71 | + protected $appPassword; |
|
72 | 72 | |
73 | - public function __construct() { |
|
74 | - $this->addType('timestamp', 'int'); |
|
75 | - $this->addType('started', 'int'); |
|
76 | - $this->addType('pollToken', 'string'); |
|
77 | - $this->addType('loginToken', 'string'); |
|
78 | - $this->addType('publicKey', 'string'); |
|
79 | - $this->addType('privateKey', 'string'); |
|
80 | - $this->addType('clientName', 'string'); |
|
81 | - $this->addType('loginName', 'string'); |
|
82 | - $this->addType('server', 'string'); |
|
83 | - $this->addType('appPassword', 'string'); |
|
84 | - } |
|
73 | + public function __construct() { |
|
74 | + $this->addType('timestamp', 'int'); |
|
75 | + $this->addType('started', 'int'); |
|
76 | + $this->addType('pollToken', 'string'); |
|
77 | + $this->addType('loginToken', 'string'); |
|
78 | + $this->addType('publicKey', 'string'); |
|
79 | + $this->addType('privateKey', 'string'); |
|
80 | + $this->addType('clientName', 'string'); |
|
81 | + $this->addType('loginName', 'string'); |
|
82 | + $this->addType('server', 'string'); |
|
83 | + $this->addType('appPassword', 'string'); |
|
84 | + } |
|
85 | 85 | } |
@@ -30,71 +30,71 @@ |
||
30 | 30 | use OCP\IDBConnection; |
31 | 31 | |
32 | 32 | class LoginFlowV2Mapper extends QBMapper { |
33 | - private const lifetime = 1200; |
|
33 | + private const lifetime = 1200; |
|
34 | 34 | |
35 | - /** @var ITimeFactory */ |
|
36 | - private $timeFactory; |
|
35 | + /** @var ITimeFactory */ |
|
36 | + private $timeFactory; |
|
37 | 37 | |
38 | - public function __construct(IDBConnection $db, ITimeFactory $timeFactory) { |
|
39 | - parent::__construct($db, 'login_flow_v2', LoginFlowV2::class); |
|
40 | - $this->timeFactory = $timeFactory; |
|
41 | - } |
|
38 | + public function __construct(IDBConnection $db, ITimeFactory $timeFactory) { |
|
39 | + parent::__construct($db, 'login_flow_v2', LoginFlowV2::class); |
|
40 | + $this->timeFactory = $timeFactory; |
|
41 | + } |
|
42 | 42 | |
43 | - /** |
|
44 | - * @param string $pollToken |
|
45 | - * @return LoginFlowV2 |
|
46 | - * @throws DoesNotExistException |
|
47 | - */ |
|
48 | - public function getByPollToken(string $pollToken): LoginFlowV2 { |
|
49 | - $qb = $this->db->getQueryBuilder(); |
|
50 | - $qb->select('*') |
|
51 | - ->from($this->getTableName()) |
|
52 | - ->where( |
|
53 | - $qb->expr()->eq('poll_token', $qb->createNamedParameter($pollToken)) |
|
54 | - ); |
|
43 | + /** |
|
44 | + * @param string $pollToken |
|
45 | + * @return LoginFlowV2 |
|
46 | + * @throws DoesNotExistException |
|
47 | + */ |
|
48 | + public function getByPollToken(string $pollToken): LoginFlowV2 { |
|
49 | + $qb = $this->db->getQueryBuilder(); |
|
50 | + $qb->select('*') |
|
51 | + ->from($this->getTableName()) |
|
52 | + ->where( |
|
53 | + $qb->expr()->eq('poll_token', $qb->createNamedParameter($pollToken)) |
|
54 | + ); |
|
55 | 55 | |
56 | - $entity = $this->findEntity($qb); |
|
57 | - return $this->validateTimestamp($entity); |
|
58 | - } |
|
56 | + $entity = $this->findEntity($qb); |
|
57 | + return $this->validateTimestamp($entity); |
|
58 | + } |
|
59 | 59 | |
60 | - /** |
|
61 | - * @param string $loginToken |
|
62 | - * @return LoginFlowV2 |
|
63 | - * @throws DoesNotExistException |
|
64 | - */ |
|
65 | - public function getByLoginToken(string $loginToken): LoginFlowV2 { |
|
66 | - $qb = $this->db->getQueryBuilder(); |
|
67 | - $qb->select('*') |
|
68 | - ->from($this->getTableName()) |
|
69 | - ->where( |
|
70 | - $qb->expr()->eq('login_token', $qb->createNamedParameter($loginToken)) |
|
71 | - ); |
|
60 | + /** |
|
61 | + * @param string $loginToken |
|
62 | + * @return LoginFlowV2 |
|
63 | + * @throws DoesNotExistException |
|
64 | + */ |
|
65 | + public function getByLoginToken(string $loginToken): LoginFlowV2 { |
|
66 | + $qb = $this->db->getQueryBuilder(); |
|
67 | + $qb->select('*') |
|
68 | + ->from($this->getTableName()) |
|
69 | + ->where( |
|
70 | + $qb->expr()->eq('login_token', $qb->createNamedParameter($loginToken)) |
|
71 | + ); |
|
72 | 72 | |
73 | - $entity = $this->findEntity($qb); |
|
74 | - return $this->validateTimestamp($entity); |
|
75 | - } |
|
73 | + $entity = $this->findEntity($qb); |
|
74 | + return $this->validateTimestamp($entity); |
|
75 | + } |
|
76 | 76 | |
77 | - public function cleanup(): void { |
|
78 | - $qb = $this->db->getQueryBuilder(); |
|
79 | - $qb->delete($this->getTableName()) |
|
80 | - ->where( |
|
81 | - $qb->expr()->lt('timestamp', $qb->createNamedParameter($this->timeFactory->getTime() - self::lifetime)) |
|
82 | - ); |
|
77 | + public function cleanup(): void { |
|
78 | + $qb = $this->db->getQueryBuilder(); |
|
79 | + $qb->delete($this->getTableName()) |
|
80 | + ->where( |
|
81 | + $qb->expr()->lt('timestamp', $qb->createNamedParameter($this->timeFactory->getTime() - self::lifetime)) |
|
82 | + ); |
|
83 | 83 | |
84 | - $qb->execute(); |
|
85 | - } |
|
84 | + $qb->execute(); |
|
85 | + } |
|
86 | 86 | |
87 | - /** |
|
88 | - * @param LoginFlowV2 $flowV2 |
|
89 | - * @return LoginFlowV2 |
|
90 | - * @throws DoesNotExistException |
|
91 | - */ |
|
92 | - private function validateTimestamp(LoginFlowV2 $flowV2): LoginFlowV2 { |
|
93 | - if ($flowV2->getTimestamp() < ($this->timeFactory->getTime() - self::lifetime)) { |
|
94 | - $this->delete($flowV2); |
|
95 | - throw new DoesNotExistException('Token expired'); |
|
96 | - } |
|
87 | + /** |
|
88 | + * @param LoginFlowV2 $flowV2 |
|
89 | + * @return LoginFlowV2 |
|
90 | + * @throws DoesNotExistException |
|
91 | + */ |
|
92 | + private function validateTimestamp(LoginFlowV2 $flowV2): LoginFlowV2 { |
|
93 | + if ($flowV2->getTimestamp() < ($this->timeFactory->getTime() - self::lifetime)) { |
|
94 | + $this->delete($flowV2); |
|
95 | + throw new DoesNotExistException('Token expired'); |
|
96 | + } |
|
97 | 97 | |
98 | - return $flowV2; |
|
99 | - } |
|
98 | + return $flowV2; |
|
99 | + } |
|
100 | 100 | } |