public function changePicture()
    {
        $id = $this->Auth->user('id');

        if ($this->request->getData('file')) {
            //Deletes any picture that already exists
            foreach (((new Folder(USER_PICTURES))->find($id . '\..+')) as $filename) {
                @unlink(USER_PICTURES . $filename);
            }

            $filename = sprintf('%s.%s', $id, pathinfo($this->request->getData('file')['tmp_name'], PATHINFO_EXTENSION));

            $uploaded = $this->Uploader->set($this->request->getData('file'))
                ->mimetype('image')
                ->save(USER_PICTURES, $filename);

            if (!$uploaded) {
                return $this->setUploadError($this->Uploader->getError());
            }

            //Updates the authentication data and clears similar thumbnails
            $this->Auth->setUser(array_merge($this->Auth->user(), ['picture' => $uploaded]));
            (new ThumbManager)->clear($uploaded);
        }
    }