| @@ 204-212 (lines=9) @@ | ||
| 201 | ); |
|
| 202 | } |
|
| 203 | ||
| 204 | if (!$backend->validateStorage($storage)) { |
|
| 205 | // unsatisfied parameters |
|
| 206 | return new DataResponse( |
|
| 207 | array( |
|
| 208 | 'message' => (string)$this->l10n->t('Unsatisfied backend parameters') |
|
| 209 | ), |
|
| 210 | Http::STATUS_UNPROCESSABLE_ENTITY |
|
| 211 | ); |
|
| 212 | } |
|
| 213 | if (!$authMechanism->validateStorage($storage)) { |
|
| 214 | // unsatisfied parameters |
|
| 215 | return new DataResponse( |
|
| @@ 213-221 (lines=9) @@ | ||
| 210 | Http::STATUS_UNPROCESSABLE_ENTITY |
|
| 211 | ); |
|
| 212 | } |
|
| 213 | if (!$authMechanism->validateStorage($storage)) { |
|
| 214 | // unsatisfied parameters |
|
| 215 | return new DataResponse( |
|
| 216 | [ |
|
| 217 | 'message' => (string)$this->l10n->t('Unsatisfied authentication mechanism parameters') |
|
| 218 | ], |
|
| 219 | Http::STATUS_UNPROCESSABLE_ENTITY |
|
| 220 | ); |
|
| 221 | } |
|
| 222 | ||
| 223 | return null; |
|
| 224 | } |
|
| @@ 162-169 (lines=8) @@ | ||
| 159 | if ($authMechanism instanceof IUserProvided) { |
|
| 160 | $authMechanism->saveBackendOptions($this->userSession->getUser(), $id, $backendOptions); |
|
| 161 | $authMechanism->manipulateStorageConfig($storage, $this->userSession->getUser()); |
|
| 162 | } else { |
|
| 163 | return new DataResponse( |
|
| 164 | [ |
|
| 165 | 'message' => (string)$this->l10n->t('Storage with id "%i" is not user editable', array($id)) |
|
| 166 | ], |
|
| 167 | Http::STATUS_FORBIDDEN |
|
| 168 | ); |
|
| 169 | } |
|
| 170 | } catch (NotFoundException $e) { |
|
| 171 | return new DataResponse( |
|
| 172 | [ |
|
| @@ 208-214 (lines=7) @@ | ||
| 205 | $this->cache->set('avatar_upload', file_get_contents($files['tmp_name'][0]), 7200); |
|
| 206 | $content = $this->cache->get('avatar_upload'); |
|
| 207 | unlink($files['tmp_name'][0]); |
|
| 208 | } else { |
|
| 209 | return new DataResponse( |
|
| 210 | ['data' => ['message' => $this->l->t('Invalid file provided')]], |
|
| 211 | Http::STATUS_BAD_REQUEST, |
|
| 212 | $headers |
|
| 213 | ); |
|
| 214 | } |
|
| 215 | } else { |
|
| 216 | //Add imgfile |
|
| 217 | return new DataResponse( |
|
| @@ 215-222 (lines=8) @@ | ||
| 212 | $headers |
|
| 213 | ); |
|
| 214 | } |
|
| 215 | } else { |
|
| 216 | //Add imgfile |
|
| 217 | return new DataResponse( |
|
| 218 | ['data' => ['message' => $this->l->t('No image or file provided')]], |
|
| 219 | Http::STATUS_BAD_REQUEST, |
|
| 220 | $headers |
|
| 221 | ); |
|
| 222 | } |
|
| 223 | ||
| 224 | try { |
|
| 225 | $image = new \OC_Image(); |
|
| @@ 245-251 (lines=7) @@ | ||
| 242 | Http::STATUS_OK, |
|
| 243 | $headers |
|
| 244 | ); |
|
| 245 | } else { |
|
| 246 | return new DataResponse( |
|
| 247 | ['data' => ['message' => $this->l->t('Invalid image')]], |
|
| 248 | Http::STATUS_OK, |
|
| 249 | $headers |
|
| 250 | ); |
|
| 251 | } |
|
| 252 | } catch (\Exception $e) { |
|
| 253 | $this->logger->logException($e, ['app' => 'core']); |
|
| 254 | return new DataResponse(['data' => ['message' => $this->l->t('An error occurred. Please contact your admin.')]], Http::STATUS_OK, $headers); |
|