improved dashboard authorization

This commit is contained in:
denisdulici
2020-01-11 22:57:19 +03:00
parent 83ba5c7691
commit 3b652df7cd
4 changed files with 27 additions and 8 deletions

View File

@@ -47,8 +47,12 @@ class DeleteDashboard extends Job
*/
public function authorize()
{
// Can't delete your last dashboard
if (user()->dashboards()->enabled()->count() == 1) {
// Can't delete last dashboard for any shared user
foreach ($this->dashboard->users as $user) {
if ($user->dashboards()->enabled()->count() > 1) {
continue;
}
$message = trans('dashboards.error.delete_last');
throw new \Exception($message);