| @@ 202-210 (lines=9) @@ | ||
| 199 | ); |
|
| 200 | } |
|
| 201 | ||
| 202 | if (!$backend->validateStorage($storage)) { |
|
| 203 | // unsatisfied parameters |
|
| 204 | return new DataResponse( |
|
| 205 | [ |
|
| 206 | 'message' => (string)$this->l10n->t('Unsatisfied backend parameters') |
|
| 207 | ], |
|
| 208 | Http::STATUS_UNPROCESSABLE_ENTITY |
|
| 209 | ); |
|
| 210 | } |
|
| 211 | if (!$authMechanism->validateStorage($storage)) { |
|
| 212 | // unsatisfied parameters |
|
| 213 | return new DataResponse( |
|
| @@ 211-219 (lines=9) @@ | ||
| 208 | Http::STATUS_UNPROCESSABLE_ENTITY |
|
| 209 | ); |
|
| 210 | } |
|
| 211 | if (!$authMechanism->validateStorage($storage)) { |
|
| 212 | // unsatisfied parameters |
|
| 213 | return new DataResponse( |
|
| 214 | [ |
|
| 215 | 'message' => (string)$this->l10n->t('Unsatisfied authentication mechanism parameters') |
|
| 216 | ], |
|
| 217 | Http::STATUS_UNPROCESSABLE_ENTITY |
|
| 218 | ); |
|
| 219 | } |
|
| 220 | ||
| 221 | return null; |
|
| 222 | } |
|
| @@ 125-127 (lines=3) @@ | ||
| 122 | if (isset($path)) { |
|
| 123 | $path = \stripslashes($path); |
|
| 124 | $node = $this->rootFolder->getUserFolder($userId)->get($path); |
|
| 125 | if (!($node instanceof \OCP\Files\File)) { |
|
| 126 | return new DataResponse(['data' => ['message' => $this->l->t('Please select a file.')]], Http::STATUS_OK, $headers); |
|
| 127 | } |
|
| 128 | if ($node->getSize() > 20*1024*1024) { |
|
| 129 | return new DataResponse( |
|
| 130 | ['data' => ['message' => $this->l->t('File is too big')]], |
|
| @@ 152-158 (lines=7) @@ | ||
| 149 | $this->cache->set('avatar_upload', \file_get_contents($files['tmp_name'][0]), 7200); |
|
| 150 | $content = $this->cache->get('avatar_upload'); |
|
| 151 | \unlink($files['tmp_name'][0]); |
|
| 152 | } else { |
|
| 153 | return new DataResponse( |
|
| 154 | ['data' => ['message' => $this->l->t('Invalid file provided')]], |
|
| 155 | Http::STATUS_BAD_REQUEST, |
|
| 156 | $headers |
|
| 157 | ); |
|
| 158 | } |
|
| 159 | } else { |
|
| 160 | //Add imgfile |
|
| 161 | return new DataResponse( |
|
| @@ 159-166 (lines=8) @@ | ||
| 156 | $headers |
|
| 157 | ); |
|
| 158 | } |
|
| 159 | } else { |
|
| 160 | //Add imgfile |
|
| 161 | return new DataResponse( |
|
| 162 | ['data' => ['message' => $this->l->t('No image or file provided')]], |
|
| 163 | Http::STATUS_BAD_REQUEST, |
|
| 164 | $headers |
|
| 165 | ); |
|
| 166 | } |
|
| 167 | ||
| 168 | try { |
|
| 169 | $image = new \OC_Image(); |
|
| @@ 189-195 (lines=7) @@ | ||
| 186 | Http::STATUS_OK, |
|
| 187 | $headers |
|
| 188 | ); |
|
| 189 | } else { |
|
| 190 | return new DataResponse( |
|
| 191 | ['data' => ['message' => $this->l->t('Invalid image')]], |
|
| 192 | Http::STATUS_OK, |
|
| 193 | $headers |
|
| 194 | ); |
|
| 195 | } |
|
| 196 | } catch (\Exception $e) { |
|
| 197 | $this->logger->logException($e, ['app' => 'core']); |
|
| 198 | return new DataResponse(['data' => ['message' => $this->l->t('An error occurred. Please contact your admin.')]], Http::STATUS_OK, $headers); |
|
| @@ 227-232 (lines=6) @@ | ||
| 224 | */ |
|
| 225 | public function getTmpAvatar() { |
|
| 226 | $tmpAvatar = $this->cache->get('tmpAvatar'); |
|
| 227 | if ($tmpAvatar === null) { |
|
| 228 | return new DataResponse(['data' => [ |
|
| 229 | 'message' => $this->l->t("No temporary profile picture available, try again") |
|
| 230 | ]], |
|
| 231 | Http::STATUS_NOT_FOUND); |
|
| 232 | } |
|
| 233 | ||
| 234 | $image = new \OC_Image($tmpAvatar); |
|
| 235 | ||
| @@ 255-258 (lines=4) @@ | ||
| 252 | public function postCroppedAvatar($crop) { |
|
| 253 | $userId = $this->userSession->getUser()->getUID(); |
|
| 254 | ||
| 255 | if ($crop === null) { |
|
| 256 | return new DataResponse(['data' => ['message' => $this->l->t("No crop data provided")]], |
|
| 257 | Http::STATUS_BAD_REQUEST); |
|
| 258 | } |
|
| 259 | ||
| 260 | if (!isset($crop['x'], $crop['y'], $crop['w'], $crop['h'])) { |
|
| 261 | return new DataResponse(['data' => ['message' => $this->l->t("No valid crop data provided")]], |
|
| @@ 266-271 (lines=6) @@ | ||
| 263 | } |
|
| 264 | ||
| 265 | $tmpAvatar = $this->cache->get('tmpAvatar'); |
|
| 266 | if ($tmpAvatar === null) { |
|
| 267 | return new DataResponse(['data' => [ |
|
| 268 | 'message' => $this->l->t("No temporary profile picture available, try again") |
|
| 269 | ]], |
|
| 270 | Http::STATUS_BAD_REQUEST); |
|
| 271 | } |
|
| 272 | ||
| 273 | $image = new \OC_Image($tmpAvatar); |
|
| 274 | $image->crop($crop['x'], $crop['y'], \round($crop['w']), \round($crop['h'])); |
|