mirror of
https://github.com/BookStackApp/BookStack.git
synced 2024-11-22 12:30:27 +08:00
Merge branch 'TBK-validation_fixes'
This commit is contained in:
commit
aa12e48d73
|
@ -86,7 +86,7 @@ class BookController extends Controller
|
|||
$this->validate($request, [
|
||||
'name' => 'required|string|max:255',
|
||||
'description' => 'string|max:1000',
|
||||
'image' => $this->getImageValidationRules(),
|
||||
'image' => 'nullable|' . $this->getImageValidationRules(),
|
||||
]);
|
||||
|
||||
$bookshelf = null;
|
||||
|
@ -153,7 +153,7 @@ class BookController extends Controller
|
|||
$this->validate($request, [
|
||||
'name' => 'required|string|max:255',
|
||||
'description' => 'string|max:1000',
|
||||
'image' => $this->getImageValidationRules(),
|
||||
'image' => 'nullable|' . $this->getImageValidationRules(),
|
||||
]);
|
||||
|
||||
$book = $this->bookRepo->update($book, $request->all());
|
||||
|
|
|
@ -85,7 +85,7 @@ class BookshelfController extends Controller
|
|||
$this->validate($request, [
|
||||
'name' => 'required|string|max:255',
|
||||
'description' => 'string|max:1000',
|
||||
'image' => $this->getImageValidationRules(),
|
||||
'image' => 'nullable|' . $this->getImageValidationRules(),
|
||||
]);
|
||||
|
||||
$bookIds = explode(',', $request->get('books', ''));
|
||||
|
@ -146,7 +146,7 @@ class BookshelfController extends Controller
|
|||
$this->validate($request, [
|
||||
'name' => 'required|string|max:255',
|
||||
'description' => 'string|max:1000',
|
||||
'image' => $this->imageRepo->getImageValidationRules(),
|
||||
'image' => 'nullable|' . $this->getImageValidationRules(),
|
||||
]);
|
||||
|
||||
|
||||
|
|
|
@ -48,7 +48,7 @@ class GalleryImageController extends Controller
|
|||
{
|
||||
$this->checkPermission('image-create-all');
|
||||
$this->validate($request, [
|
||||
'file' => $this->imageRepo->getImageValidationRules()
|
||||
'file' => $this->getImageValidationRules()
|
||||
]);
|
||||
|
||||
try {
|
||||
|
|
|
@ -44,7 +44,7 @@ class SettingController extends Controller
|
|||
$this->preventAccessInDemoMode();
|
||||
$this->checkPermission('settings-manage');
|
||||
$this->validate($request, [
|
||||
'app_logo' => $this->imageRepo->getImageValidationRules(),
|
||||
'app_logo' => 'nullable|' . $this->getImageValidationRules(),
|
||||
]);
|
||||
|
||||
// Cycles through posted settings and update them
|
||||
|
@ -57,7 +57,7 @@ class SettingController extends Controller
|
|||
}
|
||||
|
||||
// Update logo image if set
|
||||
if ($request->has('app_logo')) {
|
||||
if ($request->hasFile('app_logo')) {
|
||||
$logoFile = $request->file('app_logo');
|
||||
$this->imageRepo->destroyByType('system');
|
||||
$image = $this->imageRepo->saveNew($logoFile, 'system', 0, null, 86);
|
||||
|
|
|
@ -155,7 +155,7 @@ class UserController extends Controller
|
|||
'password' => 'min:6|required_with:password_confirm',
|
||||
'password-confirm' => 'same:password|required_with:password',
|
||||
'setting' => 'array',
|
||||
'profile_image' => $this->imageRepo->getImageValidationRules(),
|
||||
'profile_image' => 'nullable|' . $this->getImageValidationRules(),
|
||||
]);
|
||||
|
||||
$user = $this->userRepo->getById($id);
|
||||
|
@ -191,7 +191,7 @@ class UserController extends Controller
|
|||
}
|
||||
|
||||
// Save profile image if in request
|
||||
if ($request->has('profile_image')) {
|
||||
if ($request->hasFile('profile_image')) {
|
||||
$imageUpload = $request->file('profile_image');
|
||||
$this->imageRepo->destroyImage($user->avatar);
|
||||
$image = $this->imageRepo->saveNew($imageUpload, 'user', $user->id);
|
||||
|
|
|
@ -219,12 +219,4 @@ class ImageRepo
|
|||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules for image files.
|
||||
*/
|
||||
public function getImageValidationRules(): string
|
||||
{
|
||||
return 'image_extension|no_double_extension|mimes:jpeg,png,gif,bmp,webp,tiff';
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user