Files
wangruiguo d647428529
Some checks failed
Security Audit / Composer Security Audit (push) Has been cancelled
Security Audit / NPM Security Audit (push) Has been cancelled
Security Audit / CodeQL Analysis (push) Has been cancelled
OneBot: Leantime 改造版源码(BOM/Univer 表格/AI 接管/品牌替换等)
2026-09-03 18:49:20 +08:00

46 lines
1.4 KiB
PHP

<?php
namespace Leantime\Domain\Setting\Controllers;
use Leantime\Domain\Setting\Services\Setting as SettingService;
use Symfony\Component\HttpFoundation\Response;
/**
* Handles the company logo upload.
*
* A native Laravel controller (constructor DI, route-bound action). Relocated from the
* retired Api\Controllers\Setting. Bound in Setting/routes.php at the canonical
* /setting/logo plus the backward-compatible /api/setting alias used by the company-settings
* logo cropper. The 501 GET/PATCH/DELETE stubs from the old controller are not carried over.
*
* The company logo is a global setting, so the upload requires company.settings.edit (admin+)
* — the legacy endpoint had no role check, letting any authenticated user overwrite it.
*/
class Logo
{
public function __construct(private SettingService $settingService) {}
/**
* POST — store an uploaded company logo (multipart field "file").
*/
public function post(): Response
{
if (! can('company.settings.edit')) {
return response()->json(['status' => 'unauthorized'], 403);
}
if (! isset($_FILES['file'])) {
return response()->json(['status' => 'failure'], 400);
}
$_FILES['file']['name'] = 'logo.png';
$this->settingService->setLogo($_FILES);
session(['msg' => 'PICTURE_CHANGED']);
session(['msgT' => 'success']);
return response()->json(['status' => 'ok']);
}
}