query('projectAvatar', $id); if (empty($id)) { return response()->json(['status' => 'failure'], 400); } return new ImageResponse($this->projectService->getProjectAvatar($id)); } /** * POST — uploads a new avatar for the active project. * * The avatar always targets session('currentProject'); the upload requires manage * rights on that project (the legacy endpoint had no role check at all). */ public function upload(): Response { if (! isset($_FILES['file'])) { return response()->json(['error' => 'File not included'], 400); } $projectId = (int) session('currentProject'); if (! $this->projectService->userCanManageProject($projectId)) { return response()->json(['status' => 'unauthorized'], 403); } $_FILES['file']['name'] = 'profileImage-'.$projectId.'.png'; $this->projectService->setProjectAvatar($_FILES, $projectId); session(['msg' => 'PICTURE_CHANGED']); session(['msgT' => 'success']); return response()->json(['status' => 'ok']); } }