@@ -34,253 +34,253 @@ |
||
| 34 | 34 | |
| 35 | 35 | class ChangePasswordController extends Controller { |
| 36 | 36 | |
| 37 | - /** @var string */ |
|
| 38 | - private $userId; |
|
| 37 | + /** @var string */ |
|
| 38 | + private $userId; |
|
| 39 | 39 | |
| 40 | - /** @var IUserManager */ |
|
| 41 | - private $userManager; |
|
| 40 | + /** @var IUserManager */ |
|
| 41 | + private $userManager; |
|
| 42 | 42 | |
| 43 | - /** @var IL10N */ |
|
| 44 | - private $l; |
|
| 43 | + /** @var IL10N */ |
|
| 44 | + private $l; |
|
| 45 | 45 | |
| 46 | - /** @var IGroupManager */ |
|
| 47 | - private $groupManager; |
|
| 46 | + /** @var IGroupManager */ |
|
| 47 | + private $groupManager; |
|
| 48 | 48 | |
| 49 | - /** @var IUserSession */ |
|
| 50 | - private $userSession; |
|
| 49 | + /** @var IUserSession */ |
|
| 50 | + private $userSession; |
|
| 51 | 51 | |
| 52 | - /** @var IAppManager */ |
|
| 53 | - private $appManager; |
|
| 52 | + /** @var IAppManager */ |
|
| 53 | + private $appManager; |
|
| 54 | 54 | |
| 55 | - /** |
|
| 56 | - * ChangePasswordController constructor. |
|
| 57 | - * |
|
| 58 | - * @param string $appName |
|
| 59 | - * @param IRequest $request |
|
| 60 | - * @param $userId |
|
| 61 | - * @param IUserManager $userManager |
|
| 62 | - * @param IUserSession $userSession |
|
| 63 | - * @param IGroupManager $groupManager |
|
| 64 | - * @param IAppManager $appManager |
|
| 65 | - * @param IL10N $l |
|
| 66 | - */ |
|
| 67 | - public function __construct($appName, |
|
| 68 | - IRequest $request, |
|
| 69 | - $userId, |
|
| 70 | - IUserManager $userManager, |
|
| 71 | - IUserSession $userSession, |
|
| 72 | - IGroupManager $groupManager, |
|
| 73 | - IAppManager $appManager, |
|
| 74 | - IL10N $l) { |
|
| 75 | - parent::__construct($appName, $request); |
|
| 55 | + /** |
|
| 56 | + * ChangePasswordController constructor. |
|
| 57 | + * |
|
| 58 | + * @param string $appName |
|
| 59 | + * @param IRequest $request |
|
| 60 | + * @param $userId |
|
| 61 | + * @param IUserManager $userManager |
|
| 62 | + * @param IUserSession $userSession |
|
| 63 | + * @param IGroupManager $groupManager |
|
| 64 | + * @param IAppManager $appManager |
|
| 65 | + * @param IL10N $l |
|
| 66 | + */ |
|
| 67 | + public function __construct($appName, |
|
| 68 | + IRequest $request, |
|
| 69 | + $userId, |
|
| 70 | + IUserManager $userManager, |
|
| 71 | + IUserSession $userSession, |
|
| 72 | + IGroupManager $groupManager, |
|
| 73 | + IAppManager $appManager, |
|
| 74 | + IL10N $l) { |
|
| 75 | + parent::__construct($appName, $request); |
|
| 76 | 76 | |
| 77 | - $this->userId = $userId; |
|
| 78 | - $this->userManager = $userManager; |
|
| 79 | - $this->userSession = $userSession; |
|
| 80 | - $this->groupManager = $groupManager; |
|
| 81 | - $this->appManager = $appManager; |
|
| 82 | - $this->l = $l; |
|
| 83 | - } |
|
| 77 | + $this->userId = $userId; |
|
| 78 | + $this->userManager = $userManager; |
|
| 79 | + $this->userSession = $userSession; |
|
| 80 | + $this->groupManager = $groupManager; |
|
| 81 | + $this->appManager = $appManager; |
|
| 82 | + $this->l = $l; |
|
| 83 | + } |
|
| 84 | 84 | |
| 85 | - /** |
|
| 86 | - * @NoAdminRequired |
|
| 87 | - * @NoSubadminRequired |
|
| 88 | - * |
|
| 89 | - * @param string $oldpassword |
|
| 90 | - * @param string $newpassword |
|
| 91 | - * |
|
| 92 | - * @return JSONResponse |
|
| 93 | - */ |
|
| 94 | - public function changePersonalPassword($oldpassword = '', $newpassword = null) { |
|
| 95 | - /** @var IUser $user */ |
|
| 96 | - $user = $this->userManager->checkPassword($this->userId, $oldpassword); |
|
| 97 | - if ($user === false) { |
|
| 98 | - return new JSONResponse([ |
|
| 99 | - 'status' => 'error', |
|
| 100 | - 'data' => [ |
|
| 101 | - 'message' => $this->l->t('Wrong password'), |
|
| 102 | - ], |
|
| 103 | - ]); |
|
| 104 | - } |
|
| 85 | + /** |
|
| 86 | + * @NoAdminRequired |
|
| 87 | + * @NoSubadminRequired |
|
| 88 | + * |
|
| 89 | + * @param string $oldpassword |
|
| 90 | + * @param string $newpassword |
|
| 91 | + * |
|
| 92 | + * @return JSONResponse |
|
| 93 | + */ |
|
| 94 | + public function changePersonalPassword($oldpassword = '', $newpassword = null) { |
|
| 95 | + /** @var IUser $user */ |
|
| 96 | + $user = $this->userManager->checkPassword($this->userId, $oldpassword); |
|
| 97 | + if ($user === false) { |
|
| 98 | + return new JSONResponse([ |
|
| 99 | + 'status' => 'error', |
|
| 100 | + 'data' => [ |
|
| 101 | + 'message' => $this->l->t('Wrong password'), |
|
| 102 | + ], |
|
| 103 | + ]); |
|
| 104 | + } |
|
| 105 | 105 | |
| 106 | - try { |
|
| 107 | - if ($newpassword === null || $user->setPassword($newpassword) === false) { |
|
| 108 | - return new JSONResponse([ |
|
| 109 | - 'status' => 'error' |
|
| 110 | - ]); |
|
| 111 | - } |
|
| 112 | - // password policy app throws exception |
|
| 113 | - } catch(HintException $e) { |
|
| 114 | - return new JSONResponse([ |
|
| 115 | - 'status' => 'error', |
|
| 116 | - 'data' => [ |
|
| 117 | - 'message' => $e->getHint(), |
|
| 118 | - ], |
|
| 119 | - ]); |
|
| 120 | - } |
|
| 106 | + try { |
|
| 107 | + if ($newpassword === null || $user->setPassword($newpassword) === false) { |
|
| 108 | + return new JSONResponse([ |
|
| 109 | + 'status' => 'error' |
|
| 110 | + ]); |
|
| 111 | + } |
|
| 112 | + // password policy app throws exception |
|
| 113 | + } catch(HintException $e) { |
|
| 114 | + return new JSONResponse([ |
|
| 115 | + 'status' => 'error', |
|
| 116 | + 'data' => [ |
|
| 117 | + 'message' => $e->getHint(), |
|
| 118 | + ], |
|
| 119 | + ]); |
|
| 120 | + } |
|
| 121 | 121 | |
| 122 | - $this->userSession->updateSessionTokenPassword($newpassword); |
|
| 122 | + $this->userSession->updateSessionTokenPassword($newpassword); |
|
| 123 | 123 | |
| 124 | - return new JSONResponse([ |
|
| 125 | - 'status' => 'success', |
|
| 126 | - 'data' => [ |
|
| 127 | - 'message' => $this->l->t('Saved'), |
|
| 128 | - ], |
|
| 129 | - ]); |
|
| 130 | - } |
|
| 124 | + return new JSONResponse([ |
|
| 125 | + 'status' => 'success', |
|
| 126 | + 'data' => [ |
|
| 127 | + 'message' => $this->l->t('Saved'), |
|
| 128 | + ], |
|
| 129 | + ]); |
|
| 130 | + } |
|
| 131 | 131 | |
| 132 | - /** |
|
| 133 | - * @NoAdminRequired |
|
| 134 | - * @PasswordConfirmationRequired |
|
| 135 | - * |
|
| 136 | - * @param string $username |
|
| 137 | - * @param string $password |
|
| 138 | - * @param string $recoveryPassword |
|
| 139 | - * |
|
| 140 | - * @return JSONResponse |
|
| 141 | - */ |
|
| 142 | - public function changeUserPassword($username = null, $password = null, $recoveryPassword = null) { |
|
| 143 | - if ($username === null) { |
|
| 144 | - return new JSONResponse([ |
|
| 145 | - 'status' => 'error', |
|
| 146 | - 'data' => [ |
|
| 147 | - 'message' => $this->l->t('No user supplied'), |
|
| 148 | - ], |
|
| 149 | - ]); |
|
| 150 | - } |
|
| 132 | + /** |
|
| 133 | + * @NoAdminRequired |
|
| 134 | + * @PasswordConfirmationRequired |
|
| 135 | + * |
|
| 136 | + * @param string $username |
|
| 137 | + * @param string $password |
|
| 138 | + * @param string $recoveryPassword |
|
| 139 | + * |
|
| 140 | + * @return JSONResponse |
|
| 141 | + */ |
|
| 142 | + public function changeUserPassword($username = null, $password = null, $recoveryPassword = null) { |
|
| 143 | + if ($username === null) { |
|
| 144 | + return new JSONResponse([ |
|
| 145 | + 'status' => 'error', |
|
| 146 | + 'data' => [ |
|
| 147 | + 'message' => $this->l->t('No user supplied'), |
|
| 148 | + ], |
|
| 149 | + ]); |
|
| 150 | + } |
|
| 151 | 151 | |
| 152 | - if ($password === null) { |
|
| 153 | - return new JSONResponse([ |
|
| 154 | - 'status' => 'error', |
|
| 155 | - 'data' => [ |
|
| 156 | - 'message' => $this->l->t('Unable to change password'), |
|
| 157 | - ], |
|
| 158 | - ]); |
|
| 159 | - } |
|
| 152 | + if ($password === null) { |
|
| 153 | + return new JSONResponse([ |
|
| 154 | + 'status' => 'error', |
|
| 155 | + 'data' => [ |
|
| 156 | + 'message' => $this->l->t('Unable to change password'), |
|
| 157 | + ], |
|
| 158 | + ]); |
|
| 159 | + } |
|
| 160 | 160 | |
| 161 | - $currentUser = $this->userSession->getUser(); |
|
| 162 | - $targetUser = $this->userManager->get($username); |
|
| 163 | - if ($currentUser === null || $targetUser === null || |
|
| 164 | - !($this->groupManager->isAdmin($this->userId) || |
|
| 165 | - $this->groupManager->getSubAdmin()->isUserAccessible($currentUser, $targetUser)) |
|
| 166 | - ) { |
|
| 167 | - return new JSONResponse([ |
|
| 168 | - 'status' => 'error', |
|
| 169 | - 'data' => [ |
|
| 170 | - 'message' => $this->l->t('Authentication error'), |
|
| 171 | - ], |
|
| 172 | - ]); |
|
| 173 | - } |
|
| 161 | + $currentUser = $this->userSession->getUser(); |
|
| 162 | + $targetUser = $this->userManager->get($username); |
|
| 163 | + if ($currentUser === null || $targetUser === null || |
|
| 164 | + !($this->groupManager->isAdmin($this->userId) || |
|
| 165 | + $this->groupManager->getSubAdmin()->isUserAccessible($currentUser, $targetUser)) |
|
| 166 | + ) { |
|
| 167 | + return new JSONResponse([ |
|
| 168 | + 'status' => 'error', |
|
| 169 | + 'data' => [ |
|
| 170 | + 'message' => $this->l->t('Authentication error'), |
|
| 171 | + ], |
|
| 172 | + ]); |
|
| 173 | + } |
|
| 174 | 174 | |
| 175 | - if ($this->appManager->isEnabledForUser('encryption')) { |
|
| 176 | - //handle the recovery case |
|
| 177 | - $crypt = new \OCA\Encryption\Crypto\Crypt( |
|
| 178 | - \OC::$server->getLogger(), |
|
| 179 | - \OC::$server->getUserSession(), |
|
| 180 | - \OC::$server->getConfig(), |
|
| 181 | - \OC::$server->getL10N('encryption')); |
|
| 182 | - $keyStorage = \OC::$server->getEncryptionKeyStorage(); |
|
| 183 | - $util = new \OCA\Encryption\Util( |
|
| 184 | - new \OC\Files\View(), |
|
| 185 | - $crypt, |
|
| 186 | - \OC::$server->getLogger(), |
|
| 187 | - \OC::$server->getUserSession(), |
|
| 188 | - \OC::$server->getConfig(), |
|
| 189 | - \OC::$server->getUserManager()); |
|
| 190 | - $keyManager = new \OCA\Encryption\KeyManager( |
|
| 191 | - $keyStorage, |
|
| 192 | - $crypt, |
|
| 193 | - \OC::$server->getConfig(), |
|
| 194 | - \OC::$server->getUserSession(), |
|
| 195 | - new \OCA\Encryption\Session(\OC::$server->getSession()), |
|
| 196 | - \OC::$server->getLogger(), |
|
| 197 | - $util); |
|
| 198 | - $recovery = new \OCA\Encryption\Recovery( |
|
| 199 | - \OC::$server->getUserSession(), |
|
| 200 | - $crypt, |
|
| 201 | - \OC::$server->getSecureRandom(), |
|
| 202 | - $keyManager, |
|
| 203 | - \OC::$server->getConfig(), |
|
| 204 | - $keyStorage, |
|
| 205 | - \OC::$server->getEncryptionFilesHelper(), |
|
| 206 | - new \OC\Files\View()); |
|
| 207 | - $recoveryAdminEnabled = $recovery->isRecoveryKeyEnabled(); |
|
| 175 | + if ($this->appManager->isEnabledForUser('encryption')) { |
|
| 176 | + //handle the recovery case |
|
| 177 | + $crypt = new \OCA\Encryption\Crypto\Crypt( |
|
| 178 | + \OC::$server->getLogger(), |
|
| 179 | + \OC::$server->getUserSession(), |
|
| 180 | + \OC::$server->getConfig(), |
|
| 181 | + \OC::$server->getL10N('encryption')); |
|
| 182 | + $keyStorage = \OC::$server->getEncryptionKeyStorage(); |
|
| 183 | + $util = new \OCA\Encryption\Util( |
|
| 184 | + new \OC\Files\View(), |
|
| 185 | + $crypt, |
|
| 186 | + \OC::$server->getLogger(), |
|
| 187 | + \OC::$server->getUserSession(), |
|
| 188 | + \OC::$server->getConfig(), |
|
| 189 | + \OC::$server->getUserManager()); |
|
| 190 | + $keyManager = new \OCA\Encryption\KeyManager( |
|
| 191 | + $keyStorage, |
|
| 192 | + $crypt, |
|
| 193 | + \OC::$server->getConfig(), |
|
| 194 | + \OC::$server->getUserSession(), |
|
| 195 | + new \OCA\Encryption\Session(\OC::$server->getSession()), |
|
| 196 | + \OC::$server->getLogger(), |
|
| 197 | + $util); |
|
| 198 | + $recovery = new \OCA\Encryption\Recovery( |
|
| 199 | + \OC::$server->getUserSession(), |
|
| 200 | + $crypt, |
|
| 201 | + \OC::$server->getSecureRandom(), |
|
| 202 | + $keyManager, |
|
| 203 | + \OC::$server->getConfig(), |
|
| 204 | + $keyStorage, |
|
| 205 | + \OC::$server->getEncryptionFilesHelper(), |
|
| 206 | + new \OC\Files\View()); |
|
| 207 | + $recoveryAdminEnabled = $recovery->isRecoveryKeyEnabled(); |
|
| 208 | 208 | |
| 209 | - $validRecoveryPassword = false; |
|
| 210 | - $recoveryEnabledForUser = false; |
|
| 211 | - if ($recoveryAdminEnabled) { |
|
| 212 | - $validRecoveryPassword = $keyManager->checkRecoveryPassword($recoveryPassword); |
|
| 213 | - $recoveryEnabledForUser = $recovery->isRecoveryEnabledForUser($username); |
|
| 214 | - } |
|
| 209 | + $validRecoveryPassword = false; |
|
| 210 | + $recoveryEnabledForUser = false; |
|
| 211 | + if ($recoveryAdminEnabled) { |
|
| 212 | + $validRecoveryPassword = $keyManager->checkRecoveryPassword($recoveryPassword); |
|
| 213 | + $recoveryEnabledForUser = $recovery->isRecoveryEnabledForUser($username); |
|
| 214 | + } |
|
| 215 | 215 | |
| 216 | - if ($recoveryEnabledForUser && $recoveryPassword === '') { |
|
| 217 | - return new JSONResponse([ |
|
| 218 | - 'status' => 'error', |
|
| 219 | - 'data' => [ |
|
| 220 | - 'message' => $this->l->t('Please provide an admin recovery password; otherwise, all user data will be lost.'), |
|
| 221 | - ] |
|
| 222 | - ]); |
|
| 223 | - } elseif ($recoveryEnabledForUser && ! $validRecoveryPassword) { |
|
| 224 | - return new JSONResponse([ |
|
| 225 | - 'status' => 'error', |
|
| 226 | - 'data' => [ |
|
| 227 | - 'message' => $this->l->t('Wrong admin recovery password. Please check the password and try again.'), |
|
| 228 | - ] |
|
| 229 | - ]); |
|
| 230 | - } else { // now we know that everything is fine regarding the recovery password, let's try to change the password |
|
| 231 | - try { |
|
| 232 | - $result = $targetUser->setPassword($password, $recoveryPassword); |
|
| 233 | - // password policy app throws exception |
|
| 234 | - } catch(HintException $e) { |
|
| 235 | - return new JSONResponse([ |
|
| 236 | - 'status' => 'error', |
|
| 237 | - 'data' => [ |
|
| 238 | - 'message' => $e->getHint(), |
|
| 239 | - ], |
|
| 240 | - ]); |
|
| 241 | - } |
|
| 242 | - if (!$result && $recoveryEnabledForUser) { |
|
| 243 | - return new JSONResponse([ |
|
| 244 | - 'status' => 'error', |
|
| 245 | - 'data' => [ |
|
| 246 | - 'message' => $this->l->t('Backend doesn\'t support password change, but the user\'s encryption key was successfully updated.'), |
|
| 247 | - ] |
|
| 248 | - ]); |
|
| 249 | - } elseif (!$result && !$recoveryEnabledForUser) { |
|
| 250 | - return new JSONResponse([ |
|
| 251 | - 'status' => 'error', |
|
| 252 | - 'data' => [ |
|
| 253 | - 'message' => $this->l->t('Unable to change password'), |
|
| 254 | - ] |
|
| 255 | - ]); |
|
| 256 | - } |
|
| 257 | - } |
|
| 258 | - } else { |
|
| 259 | - try { |
|
| 260 | - if ($targetUser->setPassword($password) === false) { |
|
| 261 | - return new JSONResponse([ |
|
| 262 | - 'status' => 'error', |
|
| 263 | - 'data' => [ |
|
| 264 | - 'message' => $this->l->t('Unable to change password'), |
|
| 265 | - ], |
|
| 266 | - ]); |
|
| 267 | - } |
|
| 268 | - // password policy app throws exception |
|
| 269 | - } catch(HintException $e) { |
|
| 270 | - return new JSONResponse([ |
|
| 271 | - 'status' => 'error', |
|
| 272 | - 'data' => [ |
|
| 273 | - 'message' => $e->getHint(), |
|
| 274 | - ], |
|
| 275 | - ]); |
|
| 276 | - } |
|
| 277 | - } |
|
| 216 | + if ($recoveryEnabledForUser && $recoveryPassword === '') { |
|
| 217 | + return new JSONResponse([ |
|
| 218 | + 'status' => 'error', |
|
| 219 | + 'data' => [ |
|
| 220 | + 'message' => $this->l->t('Please provide an admin recovery password; otherwise, all user data will be lost.'), |
|
| 221 | + ] |
|
| 222 | + ]); |
|
| 223 | + } elseif ($recoveryEnabledForUser && ! $validRecoveryPassword) { |
|
| 224 | + return new JSONResponse([ |
|
| 225 | + 'status' => 'error', |
|
| 226 | + 'data' => [ |
|
| 227 | + 'message' => $this->l->t('Wrong admin recovery password. Please check the password and try again.'), |
|
| 228 | + ] |
|
| 229 | + ]); |
|
| 230 | + } else { // now we know that everything is fine regarding the recovery password, let's try to change the password |
|
| 231 | + try { |
|
| 232 | + $result = $targetUser->setPassword($password, $recoveryPassword); |
|
| 233 | + // password policy app throws exception |
|
| 234 | + } catch(HintException $e) { |
|
| 235 | + return new JSONResponse([ |
|
| 236 | + 'status' => 'error', |
|
| 237 | + 'data' => [ |
|
| 238 | + 'message' => $e->getHint(), |
|
| 239 | + ], |
|
| 240 | + ]); |
|
| 241 | + } |
|
| 242 | + if (!$result && $recoveryEnabledForUser) { |
|
| 243 | + return new JSONResponse([ |
|
| 244 | + 'status' => 'error', |
|
| 245 | + 'data' => [ |
|
| 246 | + 'message' => $this->l->t('Backend doesn\'t support password change, but the user\'s encryption key was successfully updated.'), |
|
| 247 | + ] |
|
| 248 | + ]); |
|
| 249 | + } elseif (!$result && !$recoveryEnabledForUser) { |
|
| 250 | + return new JSONResponse([ |
|
| 251 | + 'status' => 'error', |
|
| 252 | + 'data' => [ |
|
| 253 | + 'message' => $this->l->t('Unable to change password'), |
|
| 254 | + ] |
|
| 255 | + ]); |
|
| 256 | + } |
|
| 257 | + } |
|
| 258 | + } else { |
|
| 259 | + try { |
|
| 260 | + if ($targetUser->setPassword($password) === false) { |
|
| 261 | + return new JSONResponse([ |
|
| 262 | + 'status' => 'error', |
|
| 263 | + 'data' => [ |
|
| 264 | + 'message' => $this->l->t('Unable to change password'), |
|
| 265 | + ], |
|
| 266 | + ]); |
|
| 267 | + } |
|
| 268 | + // password policy app throws exception |
|
| 269 | + } catch(HintException $e) { |
|
| 270 | + return new JSONResponse([ |
|
| 271 | + 'status' => 'error', |
|
| 272 | + 'data' => [ |
|
| 273 | + 'message' => $e->getHint(), |
|
| 274 | + ], |
|
| 275 | + ]); |
|
| 276 | + } |
|
| 277 | + } |
|
| 278 | 278 | |
| 279 | - return new JSONResponse([ |
|
| 280 | - 'status' => 'success', |
|
| 281 | - 'data' => [ |
|
| 282 | - 'username' => $username, |
|
| 283 | - ], |
|
| 284 | - ]); |
|
| 285 | - } |
|
| 279 | + return new JSONResponse([ |
|
| 280 | + 'status' => 'success', |
|
| 281 | + 'data' => [ |
|
| 282 | + 'username' => $username, |
|
| 283 | + ], |
|
| 284 | + ]); |
|
| 285 | + } |
|
| 286 | 286 | } |
@@ -110,7 +110,7 @@ discard block |
||
| 110 | 110 | ]); |
| 111 | 111 | } |
| 112 | 112 | // password policy app throws exception |
| 113 | - } catch(HintException $e) { |
|
| 113 | + } catch (HintException $e) { |
|
| 114 | 114 | return new JSONResponse([ |
| 115 | 115 | 'status' => 'error', |
| 116 | 116 | 'data' => [ |
@@ -220,7 +220,7 @@ discard block |
||
| 220 | 220 | 'message' => $this->l->t('Please provide an admin recovery password; otherwise, all user data will be lost.'), |
| 221 | 221 | ] |
| 222 | 222 | ]); |
| 223 | - } elseif ($recoveryEnabledForUser && ! $validRecoveryPassword) { |
|
| 223 | + } elseif ($recoveryEnabledForUser && !$validRecoveryPassword) { |
|
| 224 | 224 | return new JSONResponse([ |
| 225 | 225 | 'status' => 'error', |
| 226 | 226 | 'data' => [ |
@@ -231,7 +231,7 @@ discard block |
||
| 231 | 231 | try { |
| 232 | 232 | $result = $targetUser->setPassword($password, $recoveryPassword); |
| 233 | 233 | // password policy app throws exception |
| 234 | - } catch(HintException $e) { |
|
| 234 | + } catch (HintException $e) { |
|
| 235 | 235 | return new JSONResponse([ |
| 236 | 236 | 'status' => 'error', |
| 237 | 237 | 'data' => [ |
@@ -266,7 +266,7 @@ discard block |
||
| 266 | 266 | ]); |
| 267 | 267 | } |
| 268 | 268 | // password policy app throws exception |
| 269 | - } catch(HintException $e) { |
|
| 269 | + } catch (HintException $e) { |
|
| 270 | 270 | return new JSONResponse([ |
| 271 | 271 | 'status' => 'error', |
| 272 | 272 | 'data' => [ |
@@ -7,57 +7,57 @@ discard block |
||
| 7 | 7 | <form id="ocDefaultEncryptionModule" class="section"> |
| 8 | 8 | <h2><?php p($l->t('Basic encryption module')); ?></h2> |
| 9 | 9 | |
| 10 | - <?php if ($_["initialized"] === \OCA\Encryption\Session::NOT_INITIALIZED ): ?> |
|
| 10 | + <?php if ($_["initialized"] === \OCA\Encryption\Session::NOT_INITIALIZED): ?> |
|
| 11 | 11 | |
| 12 | 12 | <?php p($l->t("Encryption App is enabled, but your keys are not initialized. Please log-out and log-in again.")); ?> |
| 13 | 13 | |
| 14 | - <?php elseif ( $_["initialized"] === \OCA\Encryption\Session::INIT_EXECUTED ): ?> |
|
| 14 | + <?php elseif ($_["initialized"] === \OCA\Encryption\Session::INIT_EXECUTED): ?> |
|
| 15 | 15 | <p> |
| 16 | 16 | <a name="changePKPasswd" /> |
| 17 | 17 | <label for="changePrivateKeyPasswd"> |
| 18 | - <em><?php p( $l->t( "Your private key password no longer matches your log-in password." ) ); ?></em> |
|
| 18 | + <em><?php p($l->t("Your private key password no longer matches your log-in password.")); ?></em> |
|
| 19 | 19 | </label> |
| 20 | 20 | <br /> |
| 21 | - <?php p( $l->t( "Set your old private key password to your current log-in password:" ) ); ?> |
|
| 22 | - <?php if ( $_["recoveryEnabledForUser"] ): |
|
| 23 | - p( $l->t( " If you don't remember your old password you can ask your administrator to recover your files." ) ); |
|
| 21 | + <?php p($l->t("Set your old private key password to your current log-in password:")); ?> |
|
| 22 | + <?php if ($_["recoveryEnabledForUser"]): |
|
| 23 | + p($l->t(" If you don't remember your old password you can ask your administrator to recover your files.")); |
|
| 24 | 24 | endif; ?> |
| 25 | 25 | <br /> |
| 26 | 26 | <input |
| 27 | 27 | type="password" |
| 28 | 28 | name="changePrivateKeyPassword" |
| 29 | 29 | id="oldPrivateKeyPassword" /> |
| 30 | - <label for="oldPrivateKeyPassword"><?php p($l->t( "Old log-in password" )); ?></label> |
|
| 30 | + <label for="oldPrivateKeyPassword"><?php p($l->t("Old log-in password")); ?></label> |
|
| 31 | 31 | <br /> |
| 32 | 32 | <input |
| 33 | 33 | type="password" |
| 34 | 34 | name="changePrivateKeyPassword" |
| 35 | 35 | id="newPrivateKeyPassword" /> |
| 36 | - <label for="newRecoveryPassword"><?php p($l->t( "Current log-in password" )); ?></label> |
|
| 36 | + <label for="newRecoveryPassword"><?php p($l->t("Current log-in password")); ?></label> |
|
| 37 | 37 | <br /> |
| 38 | 38 | <button |
| 39 | 39 | type="button" |
| 40 | 40 | name="submitChangePrivateKeyPassword" |
| 41 | - disabled><?php p($l->t( "Update Private Key Password" )); ?> |
|
| 41 | + disabled><?php p($l->t("Update Private Key Password")); ?> |
|
| 42 | 42 | </button> |
| 43 | 43 | <span class="msg"></span> |
| 44 | 44 | </p> |
| 45 | 45 | |
| 46 | - <?php elseif ( $_["recoveryEnabled"] && $_["privateKeySet"] && $_["initialized"] === \OCA\Encryption\Session::INIT_SUCCESSFUL ): ?> |
|
| 46 | + <?php elseif ($_["recoveryEnabled"] && $_["privateKeySet"] && $_["initialized"] === \OCA\Encryption\Session::INIT_SUCCESSFUL): ?> |
|
| 47 | 47 | <br /> |
| 48 | 48 | <p id="userEnableRecovery"> |
| 49 | - <label for="userEnableRecovery"><?php p( $l->t( "Enable password recovery:" ) ); ?></label> |
|
| 49 | + <label for="userEnableRecovery"><?php p($l->t("Enable password recovery:")); ?></label> |
|
| 50 | 50 | <span class="msg"></span> |
| 51 | 51 | <br /> |
| 52 | - <em><?php p( $l->t( "Enabling this option will allow you to reobtain access to your encrypted files in case of password loss" ) ); ?></em> |
|
| 52 | + <em><?php p($l->t("Enabling this option will allow you to reobtain access to your encrypted files in case of password loss")); ?></em> |
|
| 53 | 53 | <br /> |
| 54 | 54 | <input |
| 55 | 55 | type='radio' |
| 56 | 56 | id='userEnableRecovery' |
| 57 | 57 | name='userEnableRecovery' |
| 58 | 58 | value='1' |
| 59 | - <?php echo ( $_["recoveryEnabledForUser"] ? 'checked="checked"' : '' ); ?> /> |
|
| 60 | - <label for="userEnableRecovery"><?php p( $l->t( "Enabled" ) ); ?></label> |
|
| 59 | + <?php echo ($_["recoveryEnabledForUser"] ? 'checked="checked"' : ''); ?> /> |
|
| 60 | + <label for="userEnableRecovery"><?php p($l->t("Enabled")); ?></label> |
|
| 61 | 61 | <br /> |
| 62 | 62 | |
| 63 | 63 | <input |
@@ -65,8 +65,8 @@ discard block |
||
| 65 | 65 | id='userDisableRecovery' |
| 66 | 66 | name='userEnableRecovery' |
| 67 | 67 | value='0' |
| 68 | - <?php echo ( $_["recoveryEnabledForUser"] === false ? 'checked="checked"' : '' ); ?> /> |
|
| 69 | - <label for="userDisableRecovery"><?php p( $l->t( "Disabled" ) ); ?></label> |
|
| 68 | + <?php echo ($_["recoveryEnabledForUser"] === false ? 'checked="checked"' : ''); ?> /> |
|
| 69 | + <label for="userDisableRecovery"><?php p($l->t("Disabled")); ?></label> |
|
| 70 | 70 | </p> |
| 71 | 71 | <?php endif; ?> |
| 72 | 72 | </form> |
@@ -33,67 +33,67 @@ |
||
| 33 | 33 | |
| 34 | 34 | class StatusController extends Controller { |
| 35 | 35 | |
| 36 | - /** @var IL10N */ |
|
| 37 | - private $l; |
|
| 36 | + /** @var IL10N */ |
|
| 37 | + private $l; |
|
| 38 | 38 | |
| 39 | - /** @var Session */ |
|
| 40 | - private $session; |
|
| 39 | + /** @var Session */ |
|
| 40 | + private $session; |
|
| 41 | 41 | |
| 42 | - /** |
|
| 43 | - * @param string $AppName |
|
| 44 | - * @param IRequest $request |
|
| 45 | - * @param IL10N $l10n |
|
| 46 | - * @param Session $session |
|
| 47 | - */ |
|
| 48 | - public function __construct($AppName, |
|
| 49 | - IRequest $request, |
|
| 50 | - IL10N $l10n, |
|
| 51 | - Session $session |
|
| 52 | - ) { |
|
| 53 | - parent::__construct($AppName, $request); |
|
| 54 | - $this->l = $l10n; |
|
| 55 | - $this->session = $session; |
|
| 56 | - } |
|
| 42 | + /** |
|
| 43 | + * @param string $AppName |
|
| 44 | + * @param IRequest $request |
|
| 45 | + * @param IL10N $l10n |
|
| 46 | + * @param Session $session |
|
| 47 | + */ |
|
| 48 | + public function __construct($AppName, |
|
| 49 | + IRequest $request, |
|
| 50 | + IL10N $l10n, |
|
| 51 | + Session $session |
|
| 52 | + ) { |
|
| 53 | + parent::__construct($AppName, $request); |
|
| 54 | + $this->l = $l10n; |
|
| 55 | + $this->session = $session; |
|
| 56 | + } |
|
| 57 | 57 | |
| 58 | - /** |
|
| 59 | - * @NoAdminRequired |
|
| 60 | - * @return DataResponse |
|
| 61 | - */ |
|
| 62 | - public function getStatus() { |
|
| 58 | + /** |
|
| 59 | + * @NoAdminRequired |
|
| 60 | + * @return DataResponse |
|
| 61 | + */ |
|
| 62 | + public function getStatus() { |
|
| 63 | 63 | |
| 64 | - $status = 'error'; |
|
| 65 | - $message = 'no valid init status'; |
|
| 66 | - switch( $this->session->getStatus()) { |
|
| 67 | - case Session::RUN_MIGRATION: |
|
| 68 | - $status = 'interactionNeeded'; |
|
| 69 | - $message = (string)$this->l->t( |
|
| 70 | - 'You need to migrate your encryption keys from the old encryption (ownCloud <= 8.0) to the new one. Please run \'occ encryption:migrate\' or contact your administrator' |
|
| 71 | - ); |
|
| 72 | - break; |
|
| 73 | - case Session::INIT_EXECUTED: |
|
| 74 | - $status = 'interactionNeeded'; |
|
| 75 | - $message = (string)$this->l->t( |
|
| 76 | - 'Invalid private key for encryption app. Please update your private key password in your personal settings to recover access to your encrypted files.' |
|
| 77 | - ); |
|
| 78 | - break; |
|
| 79 | - case Session::NOT_INITIALIZED: |
|
| 80 | - $status = 'interactionNeeded'; |
|
| 81 | - $message = (string)$this->l->t( |
|
| 82 | - 'Encryption App is enabled, but your keys are not initialized. Please log-out and log-in again.' |
|
| 83 | - ); |
|
| 84 | - break; |
|
| 85 | - case Session::INIT_SUCCESSFUL: |
|
| 86 | - $status = 'success'; |
|
| 87 | - $message = (string)$this->l->t('Encryption app is enabled and ready'); |
|
| 88 | - } |
|
| 64 | + $status = 'error'; |
|
| 65 | + $message = 'no valid init status'; |
|
| 66 | + switch( $this->session->getStatus()) { |
|
| 67 | + case Session::RUN_MIGRATION: |
|
| 68 | + $status = 'interactionNeeded'; |
|
| 69 | + $message = (string)$this->l->t( |
|
| 70 | + 'You need to migrate your encryption keys from the old encryption (ownCloud <= 8.0) to the new one. Please run \'occ encryption:migrate\' or contact your administrator' |
|
| 71 | + ); |
|
| 72 | + break; |
|
| 73 | + case Session::INIT_EXECUTED: |
|
| 74 | + $status = 'interactionNeeded'; |
|
| 75 | + $message = (string)$this->l->t( |
|
| 76 | + 'Invalid private key for encryption app. Please update your private key password in your personal settings to recover access to your encrypted files.' |
|
| 77 | + ); |
|
| 78 | + break; |
|
| 79 | + case Session::NOT_INITIALIZED: |
|
| 80 | + $status = 'interactionNeeded'; |
|
| 81 | + $message = (string)$this->l->t( |
|
| 82 | + 'Encryption App is enabled, but your keys are not initialized. Please log-out and log-in again.' |
|
| 83 | + ); |
|
| 84 | + break; |
|
| 85 | + case Session::INIT_SUCCESSFUL: |
|
| 86 | + $status = 'success'; |
|
| 87 | + $message = (string)$this->l->t('Encryption app is enabled and ready'); |
|
| 88 | + } |
|
| 89 | 89 | |
| 90 | - return new DataResponse( |
|
| 91 | - [ |
|
| 92 | - 'status' => $status, |
|
| 93 | - 'data' => [ |
|
| 94 | - 'message' => $message] |
|
| 95 | - ] |
|
| 96 | - ); |
|
| 97 | - } |
|
| 90 | + return new DataResponse( |
|
| 91 | + [ |
|
| 92 | + 'status' => $status, |
|
| 93 | + 'data' => [ |
|
| 94 | + 'message' => $message] |
|
| 95 | + ] |
|
| 96 | + ); |
|
| 97 | + } |
|
| 98 | 98 | |
| 99 | 99 | } |
@@ -63,28 +63,28 @@ |
||
| 63 | 63 | |
| 64 | 64 | $status = 'error'; |
| 65 | 65 | $message = 'no valid init status'; |
| 66 | - switch( $this->session->getStatus()) { |
|
| 66 | + switch ($this->session->getStatus()) { |
|
| 67 | 67 | case Session::RUN_MIGRATION: |
| 68 | 68 | $status = 'interactionNeeded'; |
| 69 | - $message = (string)$this->l->t( |
|
| 69 | + $message = (string) $this->l->t( |
|
| 70 | 70 | 'You need to migrate your encryption keys from the old encryption (ownCloud <= 8.0) to the new one. Please run \'occ encryption:migrate\' or contact your administrator' |
| 71 | 71 | ); |
| 72 | 72 | break; |
| 73 | 73 | case Session::INIT_EXECUTED: |
| 74 | 74 | $status = 'interactionNeeded'; |
| 75 | - $message = (string)$this->l->t( |
|
| 75 | + $message = (string) $this->l->t( |
|
| 76 | 76 | 'Invalid private key for encryption app. Please update your private key password in your personal settings to recover access to your encrypted files.' |
| 77 | 77 | ); |
| 78 | 78 | break; |
| 79 | 79 | case Session::NOT_INITIALIZED: |
| 80 | 80 | $status = 'interactionNeeded'; |
| 81 | - $message = (string)$this->l->t( |
|
| 81 | + $message = (string) $this->l->t( |
|
| 82 | 82 | 'Encryption App is enabled, but your keys are not initialized. Please log-out and log-in again.' |
| 83 | 83 | ); |
| 84 | 84 | break; |
| 85 | 85 | case Session::INIT_SUCCESSFUL: |
| 86 | 86 | $status = 'success'; |
| 87 | - $message = (string)$this->l->t('Encryption app is enabled and ready'); |
|
| 87 | + $message = (string) $this->l->t('Encryption app is enabled and ready'); |
|
| 88 | 88 | } |
| 89 | 89 | |
| 90 | 90 | return new DataResponse( |