@@ -34,21 +34,21 @@ |
||
34 | 34 | * @since 18.0.0 |
35 | 35 | */ |
36 | 36 | interface IEntityEvent { |
37 | - /** |
|
38 | - * returns a translated name to be presented in the web interface. |
|
39 | - * |
|
40 | - * Example: "created" (en), "kreita" (eo) |
|
41 | - * |
|
42 | - * @since 18.0.0 |
|
43 | - */ |
|
44 | - public function getDisplayName(): string; |
|
37 | + /** |
|
38 | + * returns a translated name to be presented in the web interface. |
|
39 | + * |
|
40 | + * Example: "created" (en), "kreita" (eo) |
|
41 | + * |
|
42 | + * @since 18.0.0 |
|
43 | + */ |
|
44 | + public function getDisplayName(): string; |
|
45 | 45 | |
46 | - /** |
|
47 | - * returns the event name that is emitted by the EventDispatcher, e.g.: |
|
48 | - * |
|
49 | - * Example: "OCA\MyApp\Factory\Cats::postCreated" |
|
50 | - * |
|
51 | - * @since 18.0.0 |
|
52 | - */ |
|
53 | - public function getEventName(): string; |
|
46 | + /** |
|
47 | + * returns the event name that is emitted by the EventDispatcher, e.g.: |
|
48 | + * |
|
49 | + * Example: "OCA\MyApp\Factory\Cats::postCreated" |
|
50 | + * |
|
51 | + * @since 18.0.0 |
|
52 | + */ |
|
53 | + public function getEventName(): string; |
|
54 | 54 | } |
@@ -39,12 +39,12 @@ |
||
39 | 39 | */ |
40 | 40 | interface ISpecificOperation extends IOperation { |
41 | 41 | |
42 | - /** |
|
43 | - * returns the id of the entity the operator is designed for |
|
44 | - * |
|
45 | - * Example: 'WorkflowEngine_Entity_File' |
|
46 | - * |
|
47 | - * @since 18.0.0 |
|
48 | - */ |
|
49 | - public function getEntityId():string; |
|
42 | + /** |
|
43 | + * returns the id of the entity the operator is designed for |
|
44 | + * |
|
45 | + * Example: 'WorkflowEngine_Entity_File' |
|
46 | + * |
|
47 | + * @since 18.0.0 |
|
48 | + */ |
|
49 | + public function getEntityId():string; |
|
50 | 50 | } |
@@ -21,12 +21,12 @@ |
||
21 | 21 | */ |
22 | 22 | // @codeCoverageIgnoreStart |
23 | 23 | return [ |
24 | - 'routes' => [ |
|
25 | - [ |
|
26 | - 'name' => 'settings#createCodes', |
|
27 | - 'url' => '/settings/create', |
|
28 | - 'verb' => 'POST' |
|
29 | - ], |
|
30 | - ] |
|
24 | + 'routes' => [ |
|
25 | + [ |
|
26 | + 'name' => 'settings#createCodes', |
|
27 | + 'url' => '/settings/create', |
|
28 | + 'verb' => 'POST' |
|
29 | + ], |
|
30 | + ] |
|
31 | 31 | ]; |
32 | 32 | // @codeCoverageIgnoreEnd |
@@ -155,7 +155,7 @@ |
||
155 | 155 | } |
156 | 156 | |
157 | 157 | public function supportedEntities(): array { |
158 | - return [ File::class ]; |
|
158 | + return [File::class]; |
|
159 | 159 | } |
160 | 160 | |
161 | 161 | public function isAvailableForScope(int $scope): bool { |
@@ -31,63 +31,63 @@ |
||
31 | 31 | use OCP\WorkflowEngine\IFileCheck; |
32 | 32 | |
33 | 33 | class FileName extends AbstractStringCheck implements IFileCheck { |
34 | - use TFileCheck; |
|
34 | + use TFileCheck; |
|
35 | 35 | |
36 | - /** @var IRequest */ |
|
37 | - protected $request; |
|
38 | - /** @var IMountManager */ |
|
39 | - private $mountManager; |
|
36 | + /** @var IRequest */ |
|
37 | + protected $request; |
|
38 | + /** @var IMountManager */ |
|
39 | + private $mountManager; |
|
40 | 40 | |
41 | - /** |
|
42 | - * @param IL10N $l |
|
43 | - * @param IRequest $request |
|
44 | - */ |
|
45 | - public function __construct(IL10N $l, IRequest $request, IMountManager $mountManager) { |
|
46 | - parent::__construct($l); |
|
47 | - $this->request = $request; |
|
48 | - $this->mountManager = $mountManager; |
|
49 | - } |
|
41 | + /** |
|
42 | + * @param IL10N $l |
|
43 | + * @param IRequest $request |
|
44 | + */ |
|
45 | + public function __construct(IL10N $l, IRequest $request, IMountManager $mountManager) { |
|
46 | + parent::__construct($l); |
|
47 | + $this->request = $request; |
|
48 | + $this->mountManager = $mountManager; |
|
49 | + } |
|
50 | 50 | |
51 | - /** |
|
52 | - * @return string |
|
53 | - */ |
|
54 | - protected function getActualValue(): string { |
|
55 | - $fileName = $this->path === null ? '' : basename($this->path); |
|
56 | - if ($fileName === '' && (!$this->storage->isLocal() || $this->storage->instanceOfStorage(Local::class))) { |
|
57 | - // Return the mountpoint name of external storage that are not mounted as user home |
|
58 | - $mountPoints = $this->mountManager->findByStorageId($this->storage->getId()); |
|
59 | - if (empty($mountPoints) || $mountPoints[0]->getMountType() !== 'external') { |
|
60 | - return $fileName; |
|
61 | - } |
|
62 | - $mountPointPath = rtrim($mountPoints[0]->getMountPoint(), '/'); |
|
63 | - $mountPointPieces = explode('/', $mountPointPath); |
|
64 | - $mountPointName = array_pop($mountPointPieces); |
|
65 | - if (!empty($mountPointName) && $mountPointName !== 'files' && count($mountPointPieces) !== 2) { |
|
66 | - return $mountPointName; |
|
67 | - } |
|
68 | - } |
|
69 | - return $fileName; |
|
70 | - } |
|
51 | + /** |
|
52 | + * @return string |
|
53 | + */ |
|
54 | + protected function getActualValue(): string { |
|
55 | + $fileName = $this->path === null ? '' : basename($this->path); |
|
56 | + if ($fileName === '' && (!$this->storage->isLocal() || $this->storage->instanceOfStorage(Local::class))) { |
|
57 | + // Return the mountpoint name of external storage that are not mounted as user home |
|
58 | + $mountPoints = $this->mountManager->findByStorageId($this->storage->getId()); |
|
59 | + if (empty($mountPoints) || $mountPoints[0]->getMountType() !== 'external') { |
|
60 | + return $fileName; |
|
61 | + } |
|
62 | + $mountPointPath = rtrim($mountPoints[0]->getMountPoint(), '/'); |
|
63 | + $mountPointPieces = explode('/', $mountPointPath); |
|
64 | + $mountPointName = array_pop($mountPointPieces); |
|
65 | + if (!empty($mountPointName) && $mountPointName !== 'files' && count($mountPointPieces) !== 2) { |
|
66 | + return $mountPointName; |
|
67 | + } |
|
68 | + } |
|
69 | + return $fileName; |
|
70 | + } |
|
71 | 71 | |
72 | - /** |
|
73 | - * @param string $operator |
|
74 | - * @param string $checkValue |
|
75 | - * @param string $actualValue |
|
76 | - * @return bool |
|
77 | - */ |
|
78 | - protected function executeStringCheck($operator, $checkValue, $actualValue): bool { |
|
79 | - if ($operator === 'is' || $operator === '!is') { |
|
80 | - $checkValue = mb_strtolower($checkValue); |
|
81 | - $actualValue = mb_strtolower($actualValue); |
|
82 | - } |
|
83 | - return parent::executeStringCheck($operator, $checkValue, $actualValue); |
|
84 | - } |
|
72 | + /** |
|
73 | + * @param string $operator |
|
74 | + * @param string $checkValue |
|
75 | + * @param string $actualValue |
|
76 | + * @return bool |
|
77 | + */ |
|
78 | + protected function executeStringCheck($operator, $checkValue, $actualValue): bool { |
|
79 | + if ($operator === 'is' || $operator === '!is') { |
|
80 | + $checkValue = mb_strtolower($checkValue); |
|
81 | + $actualValue = mb_strtolower($actualValue); |
|
82 | + } |
|
83 | + return parent::executeStringCheck($operator, $checkValue, $actualValue); |
|
84 | + } |
|
85 | 85 | |
86 | - public function supportedEntities(): array { |
|
87 | - return [ File::class ]; |
|
88 | - } |
|
86 | + public function supportedEntities(): array { |
|
87 | + return [ File::class ]; |
|
88 | + } |
|
89 | 89 | |
90 | - public function isAvailableForScope(int $scope): bool { |
|
91 | - return true; |
|
92 | - } |
|
90 | + public function isAvailableForScope(int $scope): bool { |
|
91 | + return true; |
|
92 | + } |
|
93 | 93 | } |
@@ -33,21 +33,21 @@ |
||
33 | 33 | */ |
34 | 34 | class AddContentSecurityPolicyEvent extends Event { |
35 | 35 | |
36 | - /** @var ContentSecurityPolicyManager */ |
|
37 | - private $policyManager; |
|
36 | + /** @var ContentSecurityPolicyManager */ |
|
37 | + private $policyManager; |
|
38 | 38 | |
39 | - /** |
|
40 | - * @since 17.0.0 |
|
41 | - */ |
|
42 | - public function __construct(ContentSecurityPolicyManager $policyManager) { |
|
43 | - parent::__construct(); |
|
44 | - $this->policyManager = $policyManager; |
|
45 | - } |
|
39 | + /** |
|
40 | + * @since 17.0.0 |
|
41 | + */ |
|
42 | + public function __construct(ContentSecurityPolicyManager $policyManager) { |
|
43 | + parent::__construct(); |
|
44 | + $this->policyManager = $policyManager; |
|
45 | + } |
|
46 | 46 | |
47 | - /** |
|
48 | - * @since 17.0.0 |
|
49 | - */ |
|
50 | - public function addPolicy(EmptyContentSecurityPolicy $csp): void { |
|
51 | - $this->policyManager->addDefaultPolicy($csp); |
|
52 | - } |
|
47 | + /** |
|
48 | + * @since 17.0.0 |
|
49 | + */ |
|
50 | + public function addPolicy(EmptyContentSecurityPolicy $csp): void { |
|
51 | + $this->policyManager->addDefaultPolicy($csp); |
|
52 | + } |
|
53 | 53 | } |
@@ -33,21 +33,21 @@ |
||
33 | 33 | */ |
34 | 34 | class AddFeaturePolicyEvent extends Event { |
35 | 35 | |
36 | - /** @var FeaturePolicyManager */ |
|
37 | - private $policyManager; |
|
36 | + /** @var FeaturePolicyManager */ |
|
37 | + private $policyManager; |
|
38 | 38 | |
39 | - /** |
|
40 | - * @since 17.0.0 |
|
41 | - */ |
|
42 | - public function __construct(FeaturePolicyManager $policyManager) { |
|
43 | - parent::__construct(); |
|
44 | - $this->policyManager = $policyManager; |
|
45 | - } |
|
39 | + /** |
|
40 | + * @since 17.0.0 |
|
41 | + */ |
|
42 | + public function __construct(FeaturePolicyManager $policyManager) { |
|
43 | + parent::__construct(); |
|
44 | + $this->policyManager = $policyManager; |
|
45 | + } |
|
46 | 46 | |
47 | - /** |
|
48 | - * @since 17.0.0 |
|
49 | - */ |
|
50 | - public function addPolicy(EmptyFeaturePolicy $policy) { |
|
51 | - $this->policyManager->addDefaultPolicy($policy); |
|
52 | - } |
|
47 | + /** |
|
48 | + * @since 17.0.0 |
|
49 | + */ |
|
50 | + public function addPolicy(EmptyFeaturePolicy $policy) { |
|
51 | + $this->policyManager->addDefaultPolicy($policy); |
|
52 | + } |
|
53 | 53 | } |
@@ -266,7 +266,7 @@ discard block |
||
266 | 266 | // Save private key |
267 | 267 | if ($encryptedPrivateKey) { |
268 | 268 | $this->keyManager->setPrivateKey($user->getUID(), |
269 | - $this->crypt->generateHeader() . $encryptedPrivateKey); |
|
269 | + $this->crypt->generateHeader().$encryptedPrivateKey); |
|
270 | 270 | } else { |
271 | 271 | $this->logger->error('Encryption could not update users encryption password'); |
272 | 272 | } |
@@ -315,7 +315,7 @@ discard block |
||
315 | 315 | $encryptedKey = $this->crypt->encryptPrivateKey($keyPair['privateKey'], $newUserPassword, $userId); |
316 | 316 | |
317 | 317 | if ($encryptedKey) { |
318 | - $this->keyManager->setPrivateKey($userId, $this->crypt->generateHeader() . $encryptedKey); |
|
318 | + $this->keyManager->setPrivateKey($userId, $this->crypt->generateHeader().$encryptedKey); |
|
319 | 319 | |
320 | 320 | if ($recoveryPassword) { // if recovery key is set we can re-encrypt the key files |
321 | 321 | $this->recovery->recoverUsersFiles($recoveryPassword, $userId); |
@@ -44,304 +44,304 @@ |
||
44 | 44 | |
45 | 45 | class UserHooks implements IHook { |
46 | 46 | |
47 | - /** |
|
48 | - * list of user for which we perform a password reset |
|
49 | - * @var array |
|
50 | - */ |
|
51 | - protected static $passwordResetUsers = []; |
|
52 | - |
|
53 | - /** |
|
54 | - * @var KeyManager |
|
55 | - */ |
|
56 | - private $keyManager; |
|
57 | - /** |
|
58 | - * @var IUserManager |
|
59 | - */ |
|
60 | - private $userManager; |
|
61 | - /** |
|
62 | - * @var ILogger |
|
63 | - */ |
|
64 | - private $logger; |
|
65 | - /** |
|
66 | - * @var Setup |
|
67 | - */ |
|
68 | - private $userSetup; |
|
69 | - /** |
|
70 | - * @var IUserSession |
|
71 | - */ |
|
72 | - private $userSession; |
|
73 | - /** |
|
74 | - * @var Util |
|
75 | - */ |
|
76 | - private $util; |
|
77 | - /** |
|
78 | - * @var Session |
|
79 | - */ |
|
80 | - private $session; |
|
81 | - /** |
|
82 | - * @var Recovery |
|
83 | - */ |
|
84 | - private $recovery; |
|
85 | - /** |
|
86 | - * @var Crypt |
|
87 | - */ |
|
88 | - private $crypt; |
|
89 | - |
|
90 | - /** |
|
91 | - * UserHooks constructor. |
|
92 | - * |
|
93 | - * @param KeyManager $keyManager |
|
94 | - * @param IUserManager $userManager |
|
95 | - * @param ILogger $logger |
|
96 | - * @param Setup $userSetup |
|
97 | - * @param IUserSession $userSession |
|
98 | - * @param Util $util |
|
99 | - * @param Session $session |
|
100 | - * @param Crypt $crypt |
|
101 | - * @param Recovery $recovery |
|
102 | - */ |
|
103 | - public function __construct(KeyManager $keyManager, |
|
104 | - IUserManager $userManager, |
|
105 | - ILogger $logger, |
|
106 | - Setup $userSetup, |
|
107 | - IUserSession $userSession, |
|
108 | - Util $util, |
|
109 | - Session $session, |
|
110 | - Crypt $crypt, |
|
111 | - Recovery $recovery) { |
|
112 | - $this->keyManager = $keyManager; |
|
113 | - $this->userManager = $userManager; |
|
114 | - $this->logger = $logger; |
|
115 | - $this->userSetup = $userSetup; |
|
116 | - $this->userSession = $userSession; |
|
117 | - $this->util = $util; |
|
118 | - $this->session = $session; |
|
119 | - $this->recovery = $recovery; |
|
120 | - $this->crypt = $crypt; |
|
121 | - } |
|
122 | - |
|
123 | - /** |
|
124 | - * Connects Hooks |
|
125 | - * |
|
126 | - * @return null |
|
127 | - */ |
|
128 | - public function addHooks() { |
|
129 | - OCUtil::connectHook('OC_User', 'post_login', $this, 'login'); |
|
130 | - OCUtil::connectHook('OC_User', 'logout', $this, 'logout'); |
|
131 | - |
|
132 | - // this hooks only make sense if no master key is used |
|
133 | - if ($this->util->isMasterKeyEnabled() === false) { |
|
134 | - OCUtil::connectHook('OC_User', |
|
135 | - 'post_setPassword', |
|
136 | - $this, |
|
137 | - 'setPassphrase'); |
|
138 | - |
|
139 | - OCUtil::connectHook('OC_User', |
|
140 | - 'pre_setPassword', |
|
141 | - $this, |
|
142 | - 'preSetPassphrase'); |
|
143 | - |
|
144 | - OCUtil::connectHook('\OC\Core\LostPassword\Controller\LostController', |
|
145 | - 'post_passwordReset', |
|
146 | - $this, |
|
147 | - 'postPasswordReset'); |
|
148 | - |
|
149 | - OCUtil::connectHook('\OC\Core\LostPassword\Controller\LostController', |
|
150 | - 'pre_passwordReset', |
|
151 | - $this, |
|
152 | - 'prePasswordReset'); |
|
153 | - |
|
154 | - OCUtil::connectHook('OC_User', |
|
155 | - 'post_createUser', |
|
156 | - $this, |
|
157 | - 'postCreateUser'); |
|
158 | - |
|
159 | - OCUtil::connectHook('OC_User', |
|
160 | - 'post_deleteUser', |
|
161 | - $this, |
|
162 | - 'postDeleteUser'); |
|
163 | - } |
|
164 | - } |
|
165 | - |
|
166 | - |
|
167 | - /** |
|
168 | - * Startup encryption backend upon user login |
|
169 | - * |
|
170 | - * @note This method should never be called for users using client side encryption |
|
171 | - * @param array $params |
|
172 | - * @return boolean|null |
|
173 | - */ |
|
174 | - public function login($params) { |
|
175 | - // ensure filesystem is loaded |
|
176 | - if (!\OC\Files\Filesystem::$loaded) { |
|
177 | - $this->setupFS($params['uid']); |
|
178 | - } |
|
179 | - if ($this->util->isMasterKeyEnabled() === false) { |
|
180 | - $this->userSetup->setupUser($params['uid'], $params['password']); |
|
181 | - } |
|
182 | - |
|
183 | - $this->keyManager->init($params['uid'], $params['password']); |
|
184 | - } |
|
185 | - |
|
186 | - /** |
|
187 | - * remove keys from session during logout |
|
188 | - */ |
|
189 | - public function logout() { |
|
190 | - $this->session->clear(); |
|
191 | - } |
|
192 | - |
|
193 | - /** |
|
194 | - * setup encryption backend upon user created |
|
195 | - * |
|
196 | - * @note This method should never be called for users using client side encryption |
|
197 | - * @param array $params |
|
198 | - */ |
|
199 | - public function postCreateUser($params) { |
|
200 | - $this->userSetup->setupUser($params['uid'], $params['password']); |
|
201 | - } |
|
202 | - |
|
203 | - /** |
|
204 | - * cleanup encryption backend upon user deleted |
|
205 | - * |
|
206 | - * @param array $params : uid, password |
|
207 | - * @note This method should never be called for users using client side encryption |
|
208 | - */ |
|
209 | - public function postDeleteUser($params) { |
|
210 | - $this->keyManager->deletePublicKey($params['uid']); |
|
211 | - } |
|
212 | - |
|
213 | - public function prePasswordReset($params) { |
|
214 | - $user = $params['uid']; |
|
215 | - self::$passwordResetUsers[$user] = true; |
|
216 | - } |
|
217 | - |
|
218 | - public function postPasswordReset($params) { |
|
219 | - $uid = $params['uid']; |
|
220 | - $password = $params['password']; |
|
221 | - $this->keyManager->backupUserKeys('passwordReset', $uid); |
|
222 | - $this->keyManager->deleteUserKeys($uid); |
|
223 | - $this->userSetup->setupUser($uid, $password); |
|
224 | - unset(self::$passwordResetUsers[$uid]); |
|
225 | - } |
|
226 | - |
|
227 | - /** |
|
228 | - * If the password can't be changed within Nextcloud, than update the key password in advance. |
|
229 | - * |
|
230 | - * @param array $params : uid, password |
|
231 | - * @return boolean|null |
|
232 | - */ |
|
233 | - public function preSetPassphrase($params) { |
|
234 | - $user = $this->userManager->get($params['uid']); |
|
235 | - |
|
236 | - if ($user && !$user->canChangePassword()) { |
|
237 | - $this->setPassphrase($params); |
|
238 | - } |
|
239 | - } |
|
240 | - |
|
241 | - /** |
|
242 | - * Change a user's encryption passphrase |
|
243 | - * |
|
244 | - * @param array $params keys: uid, password |
|
245 | - * @return boolean|null |
|
246 | - */ |
|
247 | - public function setPassphrase($params) { |
|
248 | - |
|
249 | - // if we are in the process to resetting a user password, we have nothing |
|
250 | - // to do here |
|
251 | - if (isset(self::$passwordResetUsers[$params['uid']])) { |
|
252 | - return true; |
|
253 | - } |
|
254 | - |
|
255 | - // Get existing decrypted private key |
|
256 | - $user = $this->userSession->getUser(); |
|
257 | - |
|
258 | - // current logged in user changes his own password |
|
259 | - if ($user && $params['uid'] === $user->getUID()) { |
|
260 | - $privateKey = $this->session->getPrivateKey(); |
|
261 | - |
|
262 | - // Encrypt private key with new user pwd as passphrase |
|
263 | - $encryptedPrivateKey = $this->crypt->encryptPrivateKey($privateKey, $params['password'], $params['uid']); |
|
264 | - |
|
265 | - // Save private key |
|
266 | - if ($encryptedPrivateKey) { |
|
267 | - $this->keyManager->setPrivateKey($user->getUID(), |
|
268 | - $this->crypt->generateHeader() . $encryptedPrivateKey); |
|
269 | - } else { |
|
270 | - $this->logger->error('Encryption could not update users encryption password'); |
|
271 | - } |
|
272 | - |
|
273 | - // NOTE: Session does not need to be updated as the |
|
274 | - // private key has not changed, only the passphrase |
|
275 | - // used to decrypt it has changed |
|
276 | - } else { // admin changed the password for a different user, create new keys and re-encrypt file keys |
|
277 | - $userId = $params['uid']; |
|
278 | - $this->initMountPoints($userId); |
|
279 | - $recoveryPassword = isset($params['recoveryPassword']) ? $params['recoveryPassword'] : null; |
|
280 | - |
|
281 | - $recoveryKeyId = $this->keyManager->getRecoveryKeyId(); |
|
282 | - $recoveryKey = $this->keyManager->getSystemPrivateKey($recoveryKeyId); |
|
283 | - try { |
|
284 | - $decryptedRecoveryKey = $this->crypt->decryptPrivateKey($recoveryKey, $recoveryPassword); |
|
285 | - } catch (\Exception $e) { |
|
286 | - $decryptedRecoveryKey = false; |
|
287 | - } |
|
288 | - if ($decryptedRecoveryKey === false) { |
|
289 | - $message = 'Can not decrypt the recovery key. Maybe you provided the wrong password. Try again.'; |
|
290 | - throw new GenericEncryptionException($message, $message); |
|
291 | - } |
|
292 | - |
|
293 | - // we generate new keys if... |
|
294 | - // ...we have a recovery password and the user enabled the recovery key |
|
295 | - // ...encryption was activated for the first time (no keys exists) |
|
296 | - // ...the user doesn't have any files |
|
297 | - if ( |
|
298 | - ($this->recovery->isRecoveryEnabledForUser($userId) && $recoveryPassword) |
|
299 | - || !$this->keyManager->userHasKeys($userId) |
|
300 | - || !$this->util->userHasFiles($userId) |
|
301 | - ) { |
|
302 | - |
|
303 | - // backup old keys |
|
304 | - //$this->backupAllKeys('recovery'); |
|
305 | - |
|
306 | - $newUserPassword = $params['password']; |
|
307 | - |
|
308 | - $keyPair = $this->crypt->createKeyPair(); |
|
309 | - |
|
310 | - // Save public key |
|
311 | - $this->keyManager->setPublicKey($userId, $keyPair['publicKey']); |
|
312 | - |
|
313 | - // Encrypt private key with new password |
|
314 | - $encryptedKey = $this->crypt->encryptPrivateKey($keyPair['privateKey'], $newUserPassword, $userId); |
|
315 | - |
|
316 | - if ($encryptedKey) { |
|
317 | - $this->keyManager->setPrivateKey($userId, $this->crypt->generateHeader() . $encryptedKey); |
|
318 | - |
|
319 | - if ($recoveryPassword) { // if recovery key is set we can re-encrypt the key files |
|
320 | - $this->recovery->recoverUsersFiles($recoveryPassword, $userId); |
|
321 | - } |
|
322 | - } else { |
|
323 | - $this->logger->error('Encryption Could not update users encryption password'); |
|
324 | - } |
|
325 | - } |
|
326 | - } |
|
327 | - } |
|
328 | - |
|
329 | - /** |
|
330 | - * init mount points for given user |
|
331 | - * |
|
332 | - * @param string $user |
|
333 | - * @throws \OC\User\NoUserException |
|
334 | - */ |
|
335 | - protected function initMountPoints($user) { |
|
336 | - Filesystem::initMountPoints($user); |
|
337 | - } |
|
338 | - |
|
339 | - /** |
|
340 | - * setup file system for user |
|
341 | - * |
|
342 | - * @param string $uid user id |
|
343 | - */ |
|
344 | - protected function setupFS($uid) { |
|
345 | - \OC_Util::setupFS($uid); |
|
346 | - } |
|
47 | + /** |
|
48 | + * list of user for which we perform a password reset |
|
49 | + * @var array |
|
50 | + */ |
|
51 | + protected static $passwordResetUsers = []; |
|
52 | + |
|
53 | + /** |
|
54 | + * @var KeyManager |
|
55 | + */ |
|
56 | + private $keyManager; |
|
57 | + /** |
|
58 | + * @var IUserManager |
|
59 | + */ |
|
60 | + private $userManager; |
|
61 | + /** |
|
62 | + * @var ILogger |
|
63 | + */ |
|
64 | + private $logger; |
|
65 | + /** |
|
66 | + * @var Setup |
|
67 | + */ |
|
68 | + private $userSetup; |
|
69 | + /** |
|
70 | + * @var IUserSession |
|
71 | + */ |
|
72 | + private $userSession; |
|
73 | + /** |
|
74 | + * @var Util |
|
75 | + */ |
|
76 | + private $util; |
|
77 | + /** |
|
78 | + * @var Session |
|
79 | + */ |
|
80 | + private $session; |
|
81 | + /** |
|
82 | + * @var Recovery |
|
83 | + */ |
|
84 | + private $recovery; |
|
85 | + /** |
|
86 | + * @var Crypt |
|
87 | + */ |
|
88 | + private $crypt; |
|
89 | + |
|
90 | + /** |
|
91 | + * UserHooks constructor. |
|
92 | + * |
|
93 | + * @param KeyManager $keyManager |
|
94 | + * @param IUserManager $userManager |
|
95 | + * @param ILogger $logger |
|
96 | + * @param Setup $userSetup |
|
97 | + * @param IUserSession $userSession |
|
98 | + * @param Util $util |
|
99 | + * @param Session $session |
|
100 | + * @param Crypt $crypt |
|
101 | + * @param Recovery $recovery |
|
102 | + */ |
|
103 | + public function __construct(KeyManager $keyManager, |
|
104 | + IUserManager $userManager, |
|
105 | + ILogger $logger, |
|
106 | + Setup $userSetup, |
|
107 | + IUserSession $userSession, |
|
108 | + Util $util, |
|
109 | + Session $session, |
|
110 | + Crypt $crypt, |
|
111 | + Recovery $recovery) { |
|
112 | + $this->keyManager = $keyManager; |
|
113 | + $this->userManager = $userManager; |
|
114 | + $this->logger = $logger; |
|
115 | + $this->userSetup = $userSetup; |
|
116 | + $this->userSession = $userSession; |
|
117 | + $this->util = $util; |
|
118 | + $this->session = $session; |
|
119 | + $this->recovery = $recovery; |
|
120 | + $this->crypt = $crypt; |
|
121 | + } |
|
122 | + |
|
123 | + /** |
|
124 | + * Connects Hooks |
|
125 | + * |
|
126 | + * @return null |
|
127 | + */ |
|
128 | + public function addHooks() { |
|
129 | + OCUtil::connectHook('OC_User', 'post_login', $this, 'login'); |
|
130 | + OCUtil::connectHook('OC_User', 'logout', $this, 'logout'); |
|
131 | + |
|
132 | + // this hooks only make sense if no master key is used |
|
133 | + if ($this->util->isMasterKeyEnabled() === false) { |
|
134 | + OCUtil::connectHook('OC_User', |
|
135 | + 'post_setPassword', |
|
136 | + $this, |
|
137 | + 'setPassphrase'); |
|
138 | + |
|
139 | + OCUtil::connectHook('OC_User', |
|
140 | + 'pre_setPassword', |
|
141 | + $this, |
|
142 | + 'preSetPassphrase'); |
|
143 | + |
|
144 | + OCUtil::connectHook('\OC\Core\LostPassword\Controller\LostController', |
|
145 | + 'post_passwordReset', |
|
146 | + $this, |
|
147 | + 'postPasswordReset'); |
|
148 | + |
|
149 | + OCUtil::connectHook('\OC\Core\LostPassword\Controller\LostController', |
|
150 | + 'pre_passwordReset', |
|
151 | + $this, |
|
152 | + 'prePasswordReset'); |
|
153 | + |
|
154 | + OCUtil::connectHook('OC_User', |
|
155 | + 'post_createUser', |
|
156 | + $this, |
|
157 | + 'postCreateUser'); |
|
158 | + |
|
159 | + OCUtil::connectHook('OC_User', |
|
160 | + 'post_deleteUser', |
|
161 | + $this, |
|
162 | + 'postDeleteUser'); |
|
163 | + } |
|
164 | + } |
|
165 | + |
|
166 | + |
|
167 | + /** |
|
168 | + * Startup encryption backend upon user login |
|
169 | + * |
|
170 | + * @note This method should never be called for users using client side encryption |
|
171 | + * @param array $params |
|
172 | + * @return boolean|null |
|
173 | + */ |
|
174 | + public function login($params) { |
|
175 | + // ensure filesystem is loaded |
|
176 | + if (!\OC\Files\Filesystem::$loaded) { |
|
177 | + $this->setupFS($params['uid']); |
|
178 | + } |
|
179 | + if ($this->util->isMasterKeyEnabled() === false) { |
|
180 | + $this->userSetup->setupUser($params['uid'], $params['password']); |
|
181 | + } |
|
182 | + |
|
183 | + $this->keyManager->init($params['uid'], $params['password']); |
|
184 | + } |
|
185 | + |
|
186 | + /** |
|
187 | + * remove keys from session during logout |
|
188 | + */ |
|
189 | + public function logout() { |
|
190 | + $this->session->clear(); |
|
191 | + } |
|
192 | + |
|
193 | + /** |
|
194 | + * setup encryption backend upon user created |
|
195 | + * |
|
196 | + * @note This method should never be called for users using client side encryption |
|
197 | + * @param array $params |
|
198 | + */ |
|
199 | + public function postCreateUser($params) { |
|
200 | + $this->userSetup->setupUser($params['uid'], $params['password']); |
|
201 | + } |
|
202 | + |
|
203 | + /** |
|
204 | + * cleanup encryption backend upon user deleted |
|
205 | + * |
|
206 | + * @param array $params : uid, password |
|
207 | + * @note This method should never be called for users using client side encryption |
|
208 | + */ |
|
209 | + public function postDeleteUser($params) { |
|
210 | + $this->keyManager->deletePublicKey($params['uid']); |
|
211 | + } |
|
212 | + |
|
213 | + public function prePasswordReset($params) { |
|
214 | + $user = $params['uid']; |
|
215 | + self::$passwordResetUsers[$user] = true; |
|
216 | + } |
|
217 | + |
|
218 | + public function postPasswordReset($params) { |
|
219 | + $uid = $params['uid']; |
|
220 | + $password = $params['password']; |
|
221 | + $this->keyManager->backupUserKeys('passwordReset', $uid); |
|
222 | + $this->keyManager->deleteUserKeys($uid); |
|
223 | + $this->userSetup->setupUser($uid, $password); |
|
224 | + unset(self::$passwordResetUsers[$uid]); |
|
225 | + } |
|
226 | + |
|
227 | + /** |
|
228 | + * If the password can't be changed within Nextcloud, than update the key password in advance. |
|
229 | + * |
|
230 | + * @param array $params : uid, password |
|
231 | + * @return boolean|null |
|
232 | + */ |
|
233 | + public function preSetPassphrase($params) { |
|
234 | + $user = $this->userManager->get($params['uid']); |
|
235 | + |
|
236 | + if ($user && !$user->canChangePassword()) { |
|
237 | + $this->setPassphrase($params); |
|
238 | + } |
|
239 | + } |
|
240 | + |
|
241 | + /** |
|
242 | + * Change a user's encryption passphrase |
|
243 | + * |
|
244 | + * @param array $params keys: uid, password |
|
245 | + * @return boolean|null |
|
246 | + */ |
|
247 | + public function setPassphrase($params) { |
|
248 | + |
|
249 | + // if we are in the process to resetting a user password, we have nothing |
|
250 | + // to do here |
|
251 | + if (isset(self::$passwordResetUsers[$params['uid']])) { |
|
252 | + return true; |
|
253 | + } |
|
254 | + |
|
255 | + // Get existing decrypted private key |
|
256 | + $user = $this->userSession->getUser(); |
|
257 | + |
|
258 | + // current logged in user changes his own password |
|
259 | + if ($user && $params['uid'] === $user->getUID()) { |
|
260 | + $privateKey = $this->session->getPrivateKey(); |
|
261 | + |
|
262 | + // Encrypt private key with new user pwd as passphrase |
|
263 | + $encryptedPrivateKey = $this->crypt->encryptPrivateKey($privateKey, $params['password'], $params['uid']); |
|
264 | + |
|
265 | + // Save private key |
|
266 | + if ($encryptedPrivateKey) { |
|
267 | + $this->keyManager->setPrivateKey($user->getUID(), |
|
268 | + $this->crypt->generateHeader() . $encryptedPrivateKey); |
|
269 | + } else { |
|
270 | + $this->logger->error('Encryption could not update users encryption password'); |
|
271 | + } |
|
272 | + |
|
273 | + // NOTE: Session does not need to be updated as the |
|
274 | + // private key has not changed, only the passphrase |
|
275 | + // used to decrypt it has changed |
|
276 | + } else { // admin changed the password for a different user, create new keys and re-encrypt file keys |
|
277 | + $userId = $params['uid']; |
|
278 | + $this->initMountPoints($userId); |
|
279 | + $recoveryPassword = isset($params['recoveryPassword']) ? $params['recoveryPassword'] : null; |
|
280 | + |
|
281 | + $recoveryKeyId = $this->keyManager->getRecoveryKeyId(); |
|
282 | + $recoveryKey = $this->keyManager->getSystemPrivateKey($recoveryKeyId); |
|
283 | + try { |
|
284 | + $decryptedRecoveryKey = $this->crypt->decryptPrivateKey($recoveryKey, $recoveryPassword); |
|
285 | + } catch (\Exception $e) { |
|
286 | + $decryptedRecoveryKey = false; |
|
287 | + } |
|
288 | + if ($decryptedRecoveryKey === false) { |
|
289 | + $message = 'Can not decrypt the recovery key. Maybe you provided the wrong password. Try again.'; |
|
290 | + throw new GenericEncryptionException($message, $message); |
|
291 | + } |
|
292 | + |
|
293 | + // we generate new keys if... |
|
294 | + // ...we have a recovery password and the user enabled the recovery key |
|
295 | + // ...encryption was activated for the first time (no keys exists) |
|
296 | + // ...the user doesn't have any files |
|
297 | + if ( |
|
298 | + ($this->recovery->isRecoveryEnabledForUser($userId) && $recoveryPassword) |
|
299 | + || !$this->keyManager->userHasKeys($userId) |
|
300 | + || !$this->util->userHasFiles($userId) |
|
301 | + ) { |
|
302 | + |
|
303 | + // backup old keys |
|
304 | + //$this->backupAllKeys('recovery'); |
|
305 | + |
|
306 | + $newUserPassword = $params['password']; |
|
307 | + |
|
308 | + $keyPair = $this->crypt->createKeyPair(); |
|
309 | + |
|
310 | + // Save public key |
|
311 | + $this->keyManager->setPublicKey($userId, $keyPair['publicKey']); |
|
312 | + |
|
313 | + // Encrypt private key with new password |
|
314 | + $encryptedKey = $this->crypt->encryptPrivateKey($keyPair['privateKey'], $newUserPassword, $userId); |
|
315 | + |
|
316 | + if ($encryptedKey) { |
|
317 | + $this->keyManager->setPrivateKey($userId, $this->crypt->generateHeader() . $encryptedKey); |
|
318 | + |
|
319 | + if ($recoveryPassword) { // if recovery key is set we can re-encrypt the key files |
|
320 | + $this->recovery->recoverUsersFiles($recoveryPassword, $userId); |
|
321 | + } |
|
322 | + } else { |
|
323 | + $this->logger->error('Encryption Could not update users encryption password'); |
|
324 | + } |
|
325 | + } |
|
326 | + } |
|
327 | + } |
|
328 | + |
|
329 | + /** |
|
330 | + * init mount points for given user |
|
331 | + * |
|
332 | + * @param string $user |
|
333 | + * @throws \OC\User\NoUserException |
|
334 | + */ |
|
335 | + protected function initMountPoints($user) { |
|
336 | + Filesystem::initMountPoints($user); |
|
337 | + } |
|
338 | + |
|
339 | + /** |
|
340 | + * setup file system for user |
|
341 | + * |
|
342 | + * @param string $uid user id |
|
343 | + */ |
|
344 | + protected function setupFS($uid) { |
|
345 | + \OC_Util::setupFS($uid); |
|
346 | + } |
|
347 | 347 | } |
@@ -32,25 +32,25 @@ |
||
32 | 32 | |
33 | 33 | class LegacyLoadAdditionalScriptsAdapter implements IEventListener { |
34 | 34 | |
35 | - /** @var SymfonyAdapter */ |
|
36 | - private $dispatcher; |
|
37 | - |
|
38 | - public function __construct(SymfonyAdapter $dispatcher) { |
|
39 | - $this->dispatcher = $dispatcher; |
|
40 | - } |
|
41 | - |
|
42 | - public function handle(Event $event): void { |
|
43 | - if (!($event instanceof LoadAdditionalScriptsEvent)) { |
|
44 | - return; |
|
45 | - } |
|
46 | - |
|
47 | - $legacyEvent = new GenericEvent(null, ['hiddenFields' => []]); |
|
48 | - $this->dispatcher->dispatch('OCA\Files::loadAdditionalScripts', $legacyEvent); |
|
49 | - |
|
50 | - $hiddenFields = $legacyEvent->getArgument('hiddenFields'); |
|
51 | - foreach ($hiddenFields as $name => $value) { |
|
52 | - $event->addHiddenField($name, $value); |
|
53 | - } |
|
54 | - } |
|
35 | + /** @var SymfonyAdapter */ |
|
36 | + private $dispatcher; |
|
37 | + |
|
38 | + public function __construct(SymfonyAdapter $dispatcher) { |
|
39 | + $this->dispatcher = $dispatcher; |
|
40 | + } |
|
41 | + |
|
42 | + public function handle(Event $event): void { |
|
43 | + if (!($event instanceof LoadAdditionalScriptsEvent)) { |
|
44 | + return; |
|
45 | + } |
|
46 | + |
|
47 | + $legacyEvent = new GenericEvent(null, ['hiddenFields' => []]); |
|
48 | + $this->dispatcher->dispatch('OCA\Files::loadAdditionalScripts', $legacyEvent); |
|
49 | + |
|
50 | + $hiddenFields = $legacyEvent->getArgument('hiddenFields'); |
|
51 | + foreach ($hiddenFields as $name => $value) { |
|
52 | + $event->addHiddenField($name, $value); |
|
53 | + } |
|
54 | + } |
|
55 | 55 | |
56 | 56 | } |
@@ -56,9 +56,9 @@ discard block |
||
56 | 56 | |
57 | 57 | <div class="section" id="mail_general_settings"> |
58 | 58 | <form id="mail_general_settings_form" class="mail_settings"> |
59 | - <h2><?php p($l->t('Email server'));?></h2> |
|
59 | + <h2><?php p($l->t('Email server')); ?></h2> |
|
60 | 60 | <a target="_blank" rel="noreferrer noopener" class="icon-info" |
61 | - title="<?php p($l->t('Open documentation'));?>" |
|
61 | + title="<?php p($l->t('Open documentation')); ?>" |
|
62 | 62 | href="<?php p(link_to_docs('admin-email')); ?>"></a> |
63 | 63 | <p class="settings-hint"><?php p($l->t('It is important to set up this server to be able to send emails, like for password reset and notifications.')); ?></p> |
64 | 64 | <p><span id="mail_settings_msg" class="msg"></span></p> |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | $selected = 'selected="selected"'; |
73 | 73 | endif; ?> |
74 | 74 | <option value="<?php p($smtpmode[0])?>" <?php p($selected) ?>><?php p($smtpmode[1]) ?></option> |
75 | - <?php endforeach;?> |
|
75 | + <?php endforeach; ?> |
|
76 | 76 | </select> |
77 | 77 | |
78 | 78 | <label id="mail_smtpsecure_label" for="mail_smtpsecure" |
@@ -87,7 +87,7 @@ discard block |
||
87 | 87 | $selected = 'selected="selected"'; |
88 | 88 | endif; ?> |
89 | 89 | <option value="<?php p($secure)?>" <?php p($selected) ?>><?php p($name) ?></option> |
90 | - <?php endforeach;?> |
|
90 | + <?php endforeach; ?> |
|
91 | 91 | </select> |
92 | 92 | |
93 | 93 | <label id="mail_sendmailmode_label" for="mail_sendmailmode" class="<?= $_['mail_smtpmode'] !== 'sendmail' ? 'hidden' : '' ?>"> |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | <select name="mail_sendmailmode" id="mail_sendmailmode" class="<?= $_['mail_smtpmode'] !== 'sendmail' ? 'hidden' : '' ?>"> |
97 | 97 | <?php foreach ($mail_sendmailmode as $sendmailmodeValue => $sendmailmodeLabel): ?> |
98 | 98 | <option value="<?php p($sendmailmodeValue)?>" <?= $sendmailmodeValue === $_['mail_sendmailmode'] ? 'selected="selected"' : '' ?>><?php p($sendmailmodeLabel) ?></option> |
99 | - <?php endforeach;?> |
|
99 | + <?php endforeach; ?> |
|
100 | 100 | </select> |
101 | 101 | </p> |
102 | 102 | |
@@ -117,7 +117,7 @@ discard block |
||
117 | 117 | $selected = 'selected="selected"'; |
118 | 118 | endif; ?> |
119 | 119 | <option value="<?php p($authtype)?>" <?php p($selected) ?>><?php p($name) ?></option> |
120 | - <?php endforeach;?> |
|
120 | + <?php endforeach; ?> |
|
121 | 121 | </select> |
122 | 122 | |
123 | 123 | <input type="checkbox" name="mail_smtpauth" id="mail_smtpauth" class="checkbox" value="1" |
@@ -25,31 +25,31 @@ discard block |
||
25 | 25 | /** @var array $_ */ |
26 | 26 | |
27 | 27 | $mail_smtpauthtype = [ |
28 | - '' => $l->t('None'), |
|
29 | - 'LOGIN' => $l->t('Login'), |
|
30 | - 'PLAIN' => $l->t('Plain'), |
|
31 | - 'NTLM' => $l->t('NT LAN Manager'), |
|
28 | + '' => $l->t('None'), |
|
29 | + 'LOGIN' => $l->t('Login'), |
|
30 | + 'PLAIN' => $l->t('Plain'), |
|
31 | + 'NTLM' => $l->t('NT LAN Manager'), |
|
32 | 32 | ]; |
33 | 33 | |
34 | 34 | $mail_smtpsecure = [ |
35 | - '' => $l->t('None'), |
|
36 | - 'ssl' => $l->t('SSL/TLS'), |
|
37 | - 'tls' => $l->t('STARTTLS'), |
|
35 | + '' => $l->t('None'), |
|
36 | + 'ssl' => $l->t('SSL/TLS'), |
|
37 | + 'tls' => $l->t('STARTTLS'), |
|
38 | 38 | ]; |
39 | 39 | |
40 | 40 | $mail_smtpmode = [ |
41 | - ['smtp', 'SMTP'], |
|
41 | + ['smtp', 'SMTP'], |
|
42 | 42 | ]; |
43 | 43 | if ($_['sendmail_is_available']) { |
44 | - $mail_smtpmode[] = ['sendmail', 'Sendmail']; |
|
44 | + $mail_smtpmode[] = ['sendmail', 'Sendmail']; |
|
45 | 45 | } |
46 | 46 | if ($_['mail_smtpmode'] === 'qmail') { |
47 | - $mail_smtpmode[] = ['qmail', 'qmail']; |
|
47 | + $mail_smtpmode[] = ['qmail', 'qmail']; |
|
48 | 48 | } |
49 | 49 | |
50 | 50 | $mail_sendmailmode = [ |
51 | - 'smtp' => 'smtp (-bs)', |
|
52 | - 'pipe' => 'pipe (-t)' |
|
51 | + 'smtp' => 'smtp (-bs)', |
|
52 | + 'pipe' => 'pipe (-t)' |
|
53 | 53 | ]; |
54 | 54 | |
55 | 55 | ?> |
@@ -67,29 +67,29 @@ discard block |
||
67 | 67 | <label for="mail_smtpmode"><?php p($l->t('Send mode')); ?></label> |
68 | 68 | <select name="mail_smtpmode" id="mail_smtpmode"> |
69 | 69 | <?php foreach ($mail_smtpmode as $smtpmode): |
70 | - $selected = ''; |
|
71 | - if ($smtpmode[0] == $_['mail_smtpmode']): |
|
72 | - $selected = 'selected="selected"'; |
|
73 | - endif; ?> |
|
70 | + $selected = ''; |
|
71 | + if ($smtpmode[0] == $_['mail_smtpmode']): |
|
72 | + $selected = 'selected="selected"'; |
|
73 | + endif; ?> |
|
74 | 74 | <option value="<?php p($smtpmode[0])?>" <?php p($selected) ?>><?php p($smtpmode[1]) ?></option> |
75 | 75 | <?php endforeach;?> |
76 | 76 | </select> |
77 | 77 | |
78 | 78 | <label id="mail_smtpsecure_label" for="mail_smtpsecure" |
79 | 79 | <?php if ($_['mail_smtpmode'] !== 'smtp') { |
80 | - print_unescaped(' class="hidden"'); |
|
81 | - } ?>> |
|
80 | + print_unescaped(' class="hidden"'); |
|
81 | + } ?>> |
|
82 | 82 | <?php p($l->t('Encryption')); ?> |
83 | 83 | </label> |
84 | 84 | <select name="mail_smtpsecure" id="mail_smtpsecure" |
85 | 85 | <?php if ($_['mail_smtpmode'] !== 'smtp') { |
86 | - print_unescaped(' class="hidden"'); |
|
87 | - } ?>> |
|
86 | + print_unescaped(' class="hidden"'); |
|
87 | + } ?>> |
|
88 | 88 | <?php foreach ($mail_smtpsecure as $secure => $name): |
89 | - $selected = ''; |
|
90 | - if ($secure == $_['mail_smtpsecure']): |
|
91 | - $selected = 'selected="selected"'; |
|
92 | - endif; ?> |
|
89 | + $selected = ''; |
|
90 | + if ($secure == $_['mail_smtpsecure']): |
|
91 | + $selected = 'selected="selected"'; |
|
92 | + endif; ?> |
|
93 | 93 | <option value="<?php p($secure)?>" <?php p($selected) ?>><?php p($name) ?></option> |
94 | 94 | <?php endforeach;?> |
95 | 95 | </select> |
@@ -113,29 +113,29 @@ discard block |
||
113 | 113 | </p> |
114 | 114 | |
115 | 115 | <p id="setting_smtpauth" <?php if ($_['mail_smtpmode'] !== 'smtp') { |
116 | - print_unescaped(' class="hidden"'); |
|
117 | - } ?>> |
|
116 | + print_unescaped(' class="hidden"'); |
|
117 | + } ?>> |
|
118 | 118 | <label for="mail_smtpauthtype"><?php p($l->t('Authentication method')); ?></label> |
119 | 119 | <select name="mail_smtpauthtype" id="mail_smtpauthtype"> |
120 | 120 | <?php foreach ($mail_smtpauthtype as $authtype => $name): |
121 | - $selected = ''; |
|
122 | - if ($authtype == $_['mail_smtpauthtype']): |
|
123 | - $selected = 'selected="selected"'; |
|
124 | - endif; ?> |
|
121 | + $selected = ''; |
|
122 | + if ($authtype == $_['mail_smtpauthtype']): |
|
123 | + $selected = 'selected="selected"'; |
|
124 | + endif; ?> |
|
125 | 125 | <option value="<?php p($authtype)?>" <?php p($selected) ?>><?php p($name) ?></option> |
126 | 126 | <?php endforeach;?> |
127 | 127 | </select> |
128 | 128 | |
129 | 129 | <input type="checkbox" name="mail_smtpauth" id="mail_smtpauth" class="checkbox" value="1" |
130 | 130 | <?php if ($_['mail_smtpauth']) { |
131 | - print_unescaped('checked="checked"'); |
|
132 | - } ?> /> |
|
131 | + print_unescaped('checked="checked"'); |
|
132 | + } ?> /> |
|
133 | 133 | <label for="mail_smtpauth"><?php p($l->t('Authentication required')); ?></label> |
134 | 134 | </p> |
135 | 135 | |
136 | 136 | <p id="setting_smtphost" <?php if ($_['mail_smtpmode'] !== 'smtp') { |
137 | - print_unescaped(' class="hidden"'); |
|
138 | - } ?>> |
|
137 | + print_unescaped(' class="hidden"'); |
|
138 | + } ?>> |
|
139 | 139 | <label for="mail_smtphost"><?php p($l->t('Server address')); ?></label> |
140 | 140 | <input type="text" name="mail_smtphost" id="mail_smtphost" placeholder="smtp.example.com" |
141 | 141 | value="<?php p($_['mail_smtphost']) ?>" /> |
@@ -146,8 +146,8 @@ discard block |
||
146 | 146 | </form> |
147 | 147 | <form class="mail_settings" id="mail_credentials_settings"> |
148 | 148 | <p id="mail_credentials" <?php if (!$_['mail_smtpauth'] || $_['mail_smtpmode'] !== 'smtp') { |
149 | - print_unescaped(' class="hidden"'); |
|
150 | - } ?>> |
|
149 | + print_unescaped(' class="hidden"'); |
|
150 | + } ?>> |
|
151 | 151 | <label for="mail_smtpname"><?php p($l->t('Credentials')); ?></label> |
152 | 152 | <input type="text" name="mail_smtpname" id="mail_smtpname" placeholder="<?php p($l->t('SMTP Username'))?>" |
153 | 153 | value="<?php p($_['mail_smtpname']) ?>" /> |