fix:프로필 이름 수정 권한을 최고관리자로 제한

This commit is contained in:
김보곤
2026-02-03 14:01:49 +09:00
parent 35a205c48f
commit 86fa750217
3 changed files with 18 additions and 3 deletions

View File

@@ -21,8 +21,13 @@ public function authorize(): bool
*/
public function rules(): array
{
// 최고관리자만 이름 수정 가능
$nameRule = auth()->user()->isSuperAdmin()
? 'required|string|max:100'
: 'nullable';
return [
'name' => 'required|string|max:100',
'name' => $nameRule,
'phone' => 'nullable|string|max:20',
];
}

View File

@@ -9,10 +9,15 @@ class ProfileService
{
/**
* 프로필 정보 수정 (이름, 전화번호)
* 이름은 최고관리자만 수정 가능
*/
public function updateProfile(User $user, array $data): bool
{
$user->name = $data['name'];
// 최고관리자만 이름 수정 가능
if ($user->isSuperAdmin() && isset($data['name'])) {
$user->name = $data['name'];
}
$user->phone = $data['phone'] ?? null;
$user->updated_by = $user->id;

View File

@@ -60,11 +60,16 @@ class="w-full px-4 py-2 border border-gray-200 rounded-lg bg-gray-50 text-gray-5
<!-- 이름 -->
<div>
<label class="block text-sm font-medium text-gray-700 mb-1">
이름 <span class="text-red-500">*</span>
이름 @if(!auth()->user()->isSuperAdmin())<span class="text-xs text-gray-400">(관리자만 수정 가능)</span>@else<span class="text-red-500">*</span>@endif
</label>
@if(auth()->user()->isSuperAdmin())
<input type="text" name="name" required maxlength="100"
value="{{ auth()->user()->name }}"
class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500">
@else
<input type="text" value="{{ auth()->user()->name }}" readonly
class="w-full px-4 py-2 border border-gray-200 rounded-lg bg-gray-50 text-gray-500 cursor-not-allowed">
@endif
</div>
<!-- 이메일 (읽기 전용) -->