mirror of
https://github.com/BookStackApp/BookStack.git
synced 2024-08-28 21:22:30 +00:00
Added missing permission checkboxes and improved image AJAX permission responses
This commit is contained in:
parent
473261be35
commit
a14b5c33fd
@ -68,9 +68,8 @@ abstract class Controller extends BaseController
|
|||||||
protected function showPermissionError()
|
protected function showPermissionError()
|
||||||
{
|
{
|
||||||
Session::flash('error', trans('errors.permission'));
|
Session::flash('error', trans('errors.permission'));
|
||||||
throw new HttpResponseException(
|
$response = request()->wantsJson() ? response()->json(['error' => trans('errors.permissionJson')], 403) : redirect('/', 403);
|
||||||
redirect('/')
|
throw new HttpResponseException($response);
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -118,6 +118,7 @@ module.exports = function (ngApp, events) {
|
|||||||
page++;
|
page++;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
$scope.fetchData = fetchData;
|
$scope.fetchData = fetchData;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -130,12 +131,16 @@ module.exports = function (ngApp, events) {
|
|||||||
$http.put(url, this.selectedImage).then((response) => {
|
$http.put(url, this.selectedImage).then((response) => {
|
||||||
events.emit('success', 'Image details updated');
|
events.emit('success', 'Image details updated');
|
||||||
}, (response) => {
|
}, (response) => {
|
||||||
|
if (response.status === 422) {
|
||||||
var errors = response.data;
|
var errors = response.data;
|
||||||
var message = '';
|
var message = '';
|
||||||
Object.keys(errors).forEach((key) => {
|
Object.keys(errors).forEach((key) => {
|
||||||
message += errors[key].join('\n');
|
message += errors[key].join('\n');
|
||||||
});
|
});
|
||||||
events.emit('error', message);
|
events.emit('error', message);
|
||||||
|
} else if (response.status === 403) {
|
||||||
|
events.emit('error', response.data.error);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -158,6 +163,8 @@ module.exports = function (ngApp, events) {
|
|||||||
// Pages failure
|
// Pages failure
|
||||||
if (response.status === 400) {
|
if (response.status === 400) {
|
||||||
$scope.dependantPages = response.data;
|
$scope.dependantPages = response.data;
|
||||||
|
} else if (response.status === 403) {
|
||||||
|
events.emit('error', response.data.error);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
@ -8,4 +8,5 @@ return [
|
|||||||
|
|
||||||
// Pages
|
// Pages
|
||||||
'permission' => 'You do not have permission to access the requested page.',
|
'permission' => 'You do not have permission to access the requested page.',
|
||||||
|
'permissionJson' => 'You do not have permission to perform the requested action.'
|
||||||
];
|
];
|
@ -31,7 +31,9 @@
|
|||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td>Books</td>
|
<td>Books</td>
|
||||||
<td>@include('settings/roles/checkbox', ['permission' => 'book-create-all'])</td>
|
<td>
|
||||||
|
<label>@include('settings/roles/checkbox', ['permission' => 'book-create-all']) All</label>
|
||||||
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<label>@include('settings/roles/checkbox', ['permission' => 'book-update-own']) Own</label>
|
<label>@include('settings/roles/checkbox', ['permission' => 'book-update-own']) Own</label>
|
||||||
<label>@include('settings/roles/checkbox', ['permission' => 'book-update-all']) All</label>
|
<label>@include('settings/roles/checkbox', ['permission' => 'book-update-all']) All</label>
|
||||||
@ -43,7 +45,10 @@
|
|||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td>Chapters</td>
|
<td>Chapters</td>
|
||||||
<td>@include('settings/roles/checkbox', ['permission' => 'chapter-create-all'])</td>
|
<td>
|
||||||
|
<label>@include('settings/roles/checkbox', ['permission' => 'chapter-create-own']) Own</label>
|
||||||
|
<label>@include('settings/roles/checkbox', ['permission' => 'chapter-create-all']) All</label>
|
||||||
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<label>@include('settings/roles/checkbox', ['permission' => 'chapter-update-own']) Own</label>
|
<label>@include('settings/roles/checkbox', ['permission' => 'chapter-update-own']) Own</label>
|
||||||
<label>@include('settings/roles/checkbox', ['permission' => 'chapter-update-all']) All</label>
|
<label>@include('settings/roles/checkbox', ['permission' => 'chapter-update-all']) All</label>
|
||||||
@ -55,7 +60,10 @@
|
|||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td>Pages</td>
|
<td>Pages</td>
|
||||||
<td>@include('settings/roles/checkbox', ['permission' => 'page-create-all'])</td>
|
<td>
|
||||||
|
<label>@include('settings/roles/checkbox', ['permission' => 'page-create-own']) Own</label>
|
||||||
|
<label>@include('settings/roles/checkbox', ['permission' => 'page-create-all']) All</label>
|
||||||
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<label>@include('settings/roles/checkbox', ['permission' => 'page-update-own']) Own</label>
|
<label>@include('settings/roles/checkbox', ['permission' => 'page-update-own']) Own</label>
|
||||||
<label>@include('settings/roles/checkbox', ['permission' => 'page-update-all']) All</label>
|
<label>@include('settings/roles/checkbox', ['permission' => 'page-update-all']) All</label>
|
||||||
|
Loading…
Reference in New Issue
Block a user