Restrict access to forbidden links and widgets based on roles
- Wrapped Admin/Management navigation links in @role and @can permission checks. - Restricted dashboard 'Management/Ops' and 'Finance Application' widgets to authorized roles. - Applied granular visibility control to 'To-do' buckets on the dashboard for Applicant, Cashier, Accountant, and Chair.
This commit is contained in:
@@ -11,9 +11,11 @@
|
||||
<a href="{{ route('member.dashboard') }}" class="inline-flex items-center px-3 py-2 text-sm font-medium rounded-md bg-blue-50 text-blue-700 hover:bg-blue-100 border border-blue-200">
|
||||
我的會籍/繳費
|
||||
</a>
|
||||
@can('create_finance_documents')
|
||||
<a href="{{ route('admin.finance.create') }}" class="inline-flex items-center px-3 py-2 text-sm font-medium rounded-md bg-emerald-50 text-emerald-700 hover:bg-emerald-100 border border-emerald-200">
|
||||
建立財務申請
|
||||
</a>
|
||||
@endcan
|
||||
</div>
|
||||
</div>
|
||||
</x-slot>
|
||||
@@ -40,6 +42,7 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@if(Auth::user()->can('create_finance_documents') || Auth::user()->can('view_finance_documents'))
|
||||
<div class="bg-white shadow-sm sm:rounded-lg border border-gray-100 p-5">
|
||||
<div class="flex items-start justify-between">
|
||||
<div>
|
||||
@@ -49,15 +52,21 @@
|
||||
<span class="text-2xl">💼</span>
|
||||
</div>
|
||||
<div class="mt-4 flex gap-3">
|
||||
@can('create_finance_documents')
|
||||
<a href="{{ route('admin.finance.create') }}" class="inline-flex items-center px-3 py-2 text-sm font-medium rounded-md bg-emerald-600 text-white hover:bg-emerald-700">
|
||||
新增申請
|
||||
</a>
|
||||
@endcan
|
||||
@can('view_finance_documents')
|
||||
<a href="{{ route('admin.finance.index') }}" class="inline-flex items-center px-3 py-2 text-sm font-medium rounded-md border border-gray-200 text-gray-700 hover:bg-gray-50">
|
||||
查看案件列表
|
||||
</a>
|
||||
@endcan
|
||||
</div>
|
||||
</div>
|
||||
@endif
|
||||
|
||||
@if(Auth::user()->hasRole(['admin', 'membership_manager']) || Auth::user()->can('view_audit_logs'))
|
||||
<div class="bg-white shadow-sm sm:rounded-lg border border-gray-100 p-5">
|
||||
<div class="flex items-start justify-between">
|
||||
<div>
|
||||
@@ -67,28 +76,35 @@
|
||||
<span class="text-2xl">🛡️</span>
|
||||
</div>
|
||||
<div class="mt-4 flex gap-3 flex-wrap">
|
||||
@hasrole('admin|membership_manager')
|
||||
<a href="{{ route('admin.members.index') }}" class="inline-flex items-center px-3 py-2 text-sm font-medium rounded-md border border-gray-200 text-gray-700 hover:bg-gray-50">
|
||||
會員管理
|
||||
</a>
|
||||
@endhasrole
|
||||
@role('admin')
|
||||
<a href="{{ route('admin.roles.index') }}" class="inline-flex items-center px-3 py-2 text-sm font-medium rounded-md border border-gray-200 text-gray-700 hover:bg-gray-50">
|
||||
角色與權限
|
||||
</a>
|
||||
<a href="{{ route('admin.audit.index') }}" class="inline-flex items-center px-3 py-2 text-sm font-medium rounded-md border border-gray-200 text-gray-700 hover:bg-gray-50">
|
||||
審計日誌
|
||||
</a>
|
||||
@endrole
|
||||
</div>
|
||||
</div>
|
||||
@endif
|
||||
</div>
|
||||
|
||||
<!-- To-do by role (all roles see the buckets) -->
|
||||
@if(Auth::user()->hasRole(['admin', 'finance_cashier', 'payment_cashier', 'finance_accountant', 'payment_accountant', 'finance_chair', 'payment_chair']) || Auth::user()->can('create_finance_documents'))
|
||||
<div class="bg-white shadow-sm sm:rounded-lg border border-gray-100 p-6">
|
||||
<div class="flex items-center justify-between mb-4">
|
||||
<div>
|
||||
<h3 class="text-lg font-semibold text-gray-900">待辦總覽(所有角色可見)</h3>
|
||||
<h3 class="text-lg font-semibold text-gray-900">待辦總覽</h3>
|
||||
<p class="text-sm text-gray-500">依職責挑選你需要處理的事項。</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-4">
|
||||
@can('create_finance_documents')
|
||||
<div class="p-4 rounded-lg border border-gray-100 bg-slate-50">
|
||||
<div class="flex items-center justify-between">
|
||||
<h4 class="text-sm font-semibold text-gray-800">申請人 / 會員</h4><span>📝</span>
|
||||
@@ -99,6 +115,8 @@
|
||||
<li><a class="hover:text-blue-600" href="{{ route('member.dashboard') }}">查看會籍與繳費紀錄</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
@endcan
|
||||
@hasrole('finance_cashier|payment_cashier|admin')
|
||||
<div class="p-4 rounded-lg border border-gray-100 bg-slate-50">
|
||||
<div class="flex items-center justify-between">
|
||||
<h4 class="text-sm font-semibold text-gray-800">出納</h4><span>💰</span>
|
||||
@@ -109,6 +127,8 @@
|
||||
<li><a class="hover:text-blue-600" href="{{ route('admin.cashier-ledger.index') }}">填寫現金簿/匯出報表</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
@endhasrole
|
||||
@hasrole('finance_accountant|payment_accountant|admin')
|
||||
<div class="p-4 rounded-lg border border-gray-100 bg-slate-50">
|
||||
<div class="flex items-center justify-between">
|
||||
<h4 class="text-sm font-semibold text-gray-800">會計</h4><span>📊</span>
|
||||
@@ -119,6 +139,8 @@
|
||||
<li><a class="hover:text-blue-600" href="{{ route('admin.transactions.index') }}">建立交易分錄</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
@endhasrole
|
||||
@hasrole('finance_chair|payment_chair|admin')
|
||||
<div class="p-4 rounded-lg border border-gray-100 bg-slate-50">
|
||||
<div class="flex items-center justify-between">
|
||||
<h4 class="text-sm font-semibold text-gray-800">理事長/理事</h4><span>✅</span>
|
||||
@@ -129,8 +151,10 @@
|
||||
<li><a class="hover:text-blue-600" href="{{ route('admin.roles.index') }}">角色/權限檢視</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
@endhasrole
|
||||
</div>
|
||||
</div>
|
||||
@endif
|
||||
|
||||
<!-- Issues / Documents -->
|
||||
<div class="grid grid-cols-1 lg:grid-cols-2 gap-4">
|
||||
|
||||
Reference in New Issue
Block a user