mirror of
https://github.com/VueFileManager/vuefilemanager.git
synced 2026-04-18 16:22:14 +00:00
helpers refactoring
This commit is contained in:
@@ -5,7 +5,6 @@ namespace App\Actions\Fortify;
|
||||
use App\Models\Setting;
|
||||
use App\Models\User;
|
||||
use App\Models\UserSettings;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use Illuminate\Validation\Rule;
|
||||
use Laravel\Fortify\Contracts\CreatesNewUsers;
|
||||
@@ -44,7 +43,7 @@ class CreateNewUser implements CreatesNewUsers
|
||||
|
||||
$user = User::create([
|
||||
'email' => $input['email'],
|
||||
'password' => Hash::make($input['password']),
|
||||
'password' => bcrypt($input['password']),
|
||||
]);
|
||||
|
||||
UserSettings::unguard();
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
|
||||
namespace App\Actions\Fortify;
|
||||
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use Laravel\Fortify\Contracts\ResetsUserPasswords;
|
||||
|
||||
@@ -24,7 +23,7 @@ class ResetUserPassword implements ResetsUserPasswords
|
||||
])->validate();
|
||||
|
||||
$user->forceFill([
|
||||
'password' => Hash::make($input['password']),
|
||||
'password' => bcrypt($input['password']),
|
||||
])->save();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ class UpdateUserPassword implements UpdatesUserPasswords
|
||||
})->validateWithBag('updatePassword');
|
||||
|
||||
$user->forceFill([
|
||||
'password' => Hash::make($input['password']),
|
||||
'password' => bcrypt($input['password']),
|
||||
])->save();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,15 +4,12 @@ namespace App\Console\Commands;
|
||||
|
||||
use App\Models\File;
|
||||
use App\Models\Folder;
|
||||
use App\Models\Page;
|
||||
use App\Models\Share;
|
||||
use App\Services\HelperService;
|
||||
use App\Services\SetupService;
|
||||
use App\Models\Setting;
|
||||
use App\Models\User;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use Faker;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
@@ -99,7 +96,7 @@ class SetupDevEnvironment extends Command
|
||||
$user = User::forceCreate([
|
||||
'role' => 'admin',
|
||||
'email' => 'howdy@hi5ve.digital',
|
||||
'password' => Hash::make('vuefilemanager'),
|
||||
'password' => bcrypt('vuefilemanager'),
|
||||
]);
|
||||
|
||||
$user
|
||||
@@ -140,7 +137,7 @@ class SetupDevEnvironment extends Command
|
||||
$newbie = User::forceCreate([
|
||||
'role' => 'user',
|
||||
'email' => $this->faker->email,
|
||||
'password' => Hash::make('vuefilemanager'),
|
||||
'password' => bcrypt('vuefilemanager'),
|
||||
]);
|
||||
|
||||
$newbie
|
||||
@@ -186,7 +183,7 @@ class SetupDevEnvironment extends Command
|
||||
"group" => "Travel & Places",
|
||||
"subgroup" => "transport-air"
|
||||
],
|
||||
'created_at' => Carbon::now(),
|
||||
'created_at' => now(),
|
||||
]);
|
||||
|
||||
Share::factory(Share::class)
|
||||
@@ -222,7 +219,7 @@ class SetupDevEnvironment extends Command
|
||||
'group' => 'Objects',
|
||||
'subgroup' => 'light & video',
|
||||
],
|
||||
'created_at' => Carbon::now()->subMinutes(1),
|
||||
'created_at' => now()->subMinutes(1),
|
||||
]);
|
||||
|
||||
$nature = Folder::factory(Folder::class)
|
||||
@@ -263,7 +260,7 @@ class SetupDevEnvironment extends Command
|
||||
'user_id' => $user->id,
|
||||
'author' => 'user',
|
||||
'name' => 'Playable Media',
|
||||
'created_at' => Carbon::now()->subMinutes(2),
|
||||
'created_at' => now()->subMinutes(2),
|
||||
]);
|
||||
|
||||
$video = Folder::factory(Folder::class)
|
||||
@@ -288,7 +285,7 @@ class SetupDevEnvironment extends Command
|
||||
'user_id' => $user->id,
|
||||
'author' => 'user',
|
||||
'name' => 'Multi Level Folder',
|
||||
'created_at' => Carbon::now()->subMinutes(3),
|
||||
'created_at' => now()->subMinutes(3),
|
||||
]);
|
||||
|
||||
$first_level = Folder::factory(Folder::class)
|
||||
@@ -321,7 +318,7 @@ class SetupDevEnvironment extends Command
|
||||
'user_id' => $user->id,
|
||||
'author' => 'user',
|
||||
'name' => 'Documents',
|
||||
'created_at' => Carbon::now()->subMinutes(4),
|
||||
'created_at' => now()->subMinutes(4),
|
||||
]);
|
||||
|
||||
Share::factory(Share::class)
|
||||
@@ -341,7 +338,7 @@ class SetupDevEnvironment extends Command
|
||||
'user_id' => $user->id,
|
||||
'author' => 'user',
|
||||
'name' => 'Videohive by MakingCG',
|
||||
'created_at' => Carbon::now()->subMinutes(5),
|
||||
'created_at' => now()->subMinutes(5),
|
||||
]);
|
||||
|
||||
$user
|
||||
@@ -393,7 +390,7 @@ class SetupDevEnvironment extends Command
|
||||
'author' => 'user',
|
||||
'mimetype' => $file['mimetype'],
|
||||
'filesize' => rand(1000000, 4000000),
|
||||
'created_at' => Carbon::now()->subMinutes(rand(1, 5)),
|
||||
'created_at' => now()->subMinutes(rand(1, 5)),
|
||||
]);
|
||||
});
|
||||
|
||||
@@ -437,7 +434,7 @@ class SetupDevEnvironment extends Command
|
||||
'author' => 'user',
|
||||
'mimetype' => $file['mimetype'],
|
||||
'filesize' => rand(1000000, 4000000),
|
||||
'created_at' => Carbon::now()->subMinutes(rand(1, 5)),
|
||||
'created_at' => now()->subMinutes(rand(1, 5)),
|
||||
]);
|
||||
});
|
||||
|
||||
@@ -471,7 +468,7 @@ class SetupDevEnvironment extends Command
|
||||
'author' => 'user',
|
||||
'mimetype' => $file['mimetype'],
|
||||
'filesize' => rand(1000000, 4000000),
|
||||
'created_at' => Carbon::now()->subMinutes(rand(1, 5)),
|
||||
'created_at' => now()->subMinutes(rand(1, 5)),
|
||||
]);
|
||||
});
|
||||
|
||||
@@ -530,7 +527,7 @@ class SetupDevEnvironment extends Command
|
||||
'author' => 'visitor',
|
||||
'mimetype' => $file['mimetype'],
|
||||
'filesize' => rand(1000000, 4000000),
|
||||
'created_at' => Carbon::now()->subMinutes(rand(1, 5)),
|
||||
'created_at' => now()->subMinutes(rand(1, 5)),
|
||||
]);
|
||||
});
|
||||
|
||||
@@ -558,7 +555,7 @@ class SetupDevEnvironment extends Command
|
||||
'author' => 'user',
|
||||
'mimetype' => 'mp4',
|
||||
'filesize' => rand(1000000, 4000000),
|
||||
'created_at' => Carbon::now()->subMinutes(rand(1, 5)),
|
||||
'created_at' => now()->subMinutes(rand(1, 5)),
|
||||
]);
|
||||
});
|
||||
|
||||
@@ -583,7 +580,7 @@ class SetupDevEnvironment extends Command
|
||||
'author' => 'user',
|
||||
'mimetype' => 'mp4',
|
||||
'filesize' => rand(1000000, 4000000),
|
||||
'created_at' => Carbon::now()->subMinutes(rand(1, 5)),
|
||||
'created_at' => now()->subMinutes(rand(1, 5)),
|
||||
]);
|
||||
});
|
||||
|
||||
@@ -608,7 +605,7 @@ class SetupDevEnvironment extends Command
|
||||
'author' => 'user',
|
||||
'mimetype' => 'mp3',
|
||||
'filesize' => rand(1000000, 4000000),
|
||||
'created_at' => Carbon::now()->subMinutes(rand(1, 5)),
|
||||
'created_at' => now()->subMinutes(rand(1, 5)),
|
||||
]);
|
||||
});
|
||||
|
||||
@@ -647,7 +644,7 @@ class SetupDevEnvironment extends Command
|
||||
'mimetype' => 'jpg',
|
||||
'filesize' => rand(1000000, 4000000),
|
||||
'thumbnail' => $this->helper->create_image_thumbnail("files/$user->id/$basename", $file, $user->id),
|
||||
'created_at' => Carbon::now()->subMinutes(rand(1, 5)),
|
||||
'created_at' => now()->subMinutes(rand(1, 5)),
|
||||
]);
|
||||
});
|
||||
|
||||
@@ -681,7 +678,7 @@ class SetupDevEnvironment extends Command
|
||||
'mimetype' => 'jpg',
|
||||
'filesize' => rand(1000000, 4000000),
|
||||
'thumbnail' => $this->helper->create_image_thumbnail("files/$user->id/$basename", $file, $user->id),
|
||||
'created_at' => Carbon::now()->subMinutes(rand(1, 5)),
|
||||
'created_at' => now()->subMinutes(rand(1, 5)),
|
||||
]);
|
||||
});
|
||||
|
||||
@@ -719,7 +716,7 @@ class SetupDevEnvironment extends Command
|
||||
'mimetype' => 'jpg',
|
||||
'filesize' => rand(1000000, 4000000),
|
||||
'thumbnail' => $this->helper->create_image_thumbnail("files/$user->id/$basename", $file, $user->id),
|
||||
'created_at' => Carbon::now()->subMinutes(rand(1, 5)),
|
||||
'created_at' => now()->subMinutes(rand(1, 5)),
|
||||
]);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -56,9 +56,7 @@ class LanguageController extends Controller
|
||||
*/
|
||||
public function create_language(CreateLanguageRequest $request)
|
||||
{
|
||||
if (is_demo()) {
|
||||
return $this->demo->response_with_no_content();
|
||||
}
|
||||
abort_if(is_demo(), 204, 'Done.');
|
||||
|
||||
$language = Language::create([
|
||||
'name' => $request->input('name'),
|
||||
@@ -78,9 +76,7 @@ class LanguageController extends Controller
|
||||
*/
|
||||
public function update_language(UpdateLanguageRequest $request, Language $language)
|
||||
{
|
||||
if (is_demo()) {
|
||||
return $this->demo->response_with_no_content();
|
||||
}
|
||||
abort_if(is_demo(), 204, 'Done.');
|
||||
|
||||
$language->update(make_single_input($request));
|
||||
|
||||
@@ -98,9 +94,7 @@ class LanguageController extends Controller
|
||||
*/
|
||||
public function update_string(UpdateStringRequest $request, Language $language)
|
||||
{
|
||||
if (is_demo()) {
|
||||
return $this->demo->response_with_no_content();
|
||||
}
|
||||
abort_if(is_demo(), 204, 'Done.');
|
||||
|
||||
$language
|
||||
->languageStrings()
|
||||
@@ -122,9 +116,7 @@ class LanguageController extends Controller
|
||||
*/
|
||||
public function delete_language(Language $language)
|
||||
{
|
||||
if (is_demo()) {
|
||||
return $this->demo->response_with_no_content();
|
||||
}
|
||||
abort_if(is_demo(), 204, 'Done.');
|
||||
|
||||
if ($language->locale === 'en') {
|
||||
abort(401, "Sorry, you can't delete default language.");
|
||||
|
||||
@@ -51,9 +51,7 @@ class PagesController extends Controller
|
||||
*/
|
||||
public function update(Request $request, Page $page)
|
||||
{
|
||||
if (is_demo()) {
|
||||
return $this->demo->response_with_no_content();
|
||||
}
|
||||
abort_if(is_demo(), 204, 'Done.');
|
||||
|
||||
$page->update(
|
||||
make_single_input($request)
|
||||
|
||||
@@ -110,9 +110,7 @@ class PlanController extends Controller
|
||||
*/
|
||||
public function update(Request $request, $id)
|
||||
{
|
||||
if (is_demo()) {
|
||||
return $this->demo->response_with_no_content();
|
||||
}
|
||||
abort_if(is_demo(), 204, 'Done.');
|
||||
|
||||
// Update plan
|
||||
$this->stripe->updatePlan($request, $id);
|
||||
@@ -131,9 +129,7 @@ class PlanController extends Controller
|
||||
*/
|
||||
public function delete($id)
|
||||
{
|
||||
if (is_demo()) {
|
||||
return $this->demo->response_with_no_content();
|
||||
}
|
||||
abort_if(is_demo(), 204, 'Done.');
|
||||
|
||||
// Delete plan
|
||||
$this->stripe->deletePlan($id);
|
||||
|
||||
@@ -49,9 +49,7 @@ class SettingController extends Controller
|
||||
*/
|
||||
public function update(Request $request)
|
||||
{
|
||||
if (is_demo()) {
|
||||
return $this->demo->response_with_no_content();
|
||||
}
|
||||
abort_if(is_demo(), 204, 'Done.');
|
||||
|
||||
// Store image if exist
|
||||
if ($request->hasFile($request->name)) {
|
||||
@@ -84,9 +82,7 @@ class SettingController extends Controller
|
||||
public function set_email(Request $request)
|
||||
{
|
||||
// TODO: pridat validator do requestu
|
||||
if (is_demo()) {
|
||||
return $this->demo->response_with_no_content();
|
||||
}
|
||||
abort_if(is_demo(), 204, 'Done.');
|
||||
|
||||
if (!app()->runningUnitTests()) {
|
||||
|
||||
@@ -178,9 +174,7 @@ class SettingController extends Controller
|
||||
*/
|
||||
public function flush_cache()
|
||||
{
|
||||
if (is_demo()) {
|
||||
return $this->demo->response_with_no_content();
|
||||
}
|
||||
abort_if(is_demo(), 204, 'Done.');
|
||||
|
||||
if (!app()->runningUnitTests()) {
|
||||
Artisan::call('cache:clear');
|
||||
|
||||
@@ -22,7 +22,6 @@ use Illuminate\Contracts\Foundation\Application;
|
||||
use Illuminate\Contracts\Routing\ResponseFactory;
|
||||
use Illuminate\Http\Response;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use Illuminate\Support\Facades\Password;
|
||||
use Storage;
|
||||
|
||||
@@ -182,7 +181,7 @@ class UserController extends Controller
|
||||
$user = User::forceCreate([
|
||||
'role' => $request->role,
|
||||
'email' => $request->email,
|
||||
'password' => Hash::make($request->password),
|
||||
'password' => bcrypt($request->password),
|
||||
]);
|
||||
|
||||
UserSettings::unguard();
|
||||
|
||||
@@ -21,7 +21,6 @@ use Illuminate\Contracts\Routing\ResponseFactory;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use Illuminate\Support\Str;
|
||||
use Schema;
|
||||
@@ -413,7 +412,7 @@ class SetupWizardController extends Controller
|
||||
$user = User::forceCreate([
|
||||
'role' => 'admin',
|
||||
'email' => $request->email,
|
||||
'password' => Hash::make($request->password),
|
||||
'password' => bcrypt($request->password),
|
||||
]);
|
||||
|
||||
$user
|
||||
|
||||
@@ -3,14 +3,8 @@
|
||||
namespace App\Http\Controllers\Auth;
|
||||
|
||||
use App\Http\Requests\Auth\CheckAccountRequest;
|
||||
use App\Models\Setting;
|
||||
use App\Models\User;
|
||||
use App\Models\UserSettings;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use Illuminate\Support\Facades\Route;
|
||||
|
||||
class AuthController extends Controller
|
||||
{
|
||||
|
||||
@@ -82,9 +82,7 @@ class EditItemsController extends Controller
|
||||
*/
|
||||
public function delete_item(DeleteItemRequest $request)
|
||||
{
|
||||
if (is_demo_account('howdy@hi5ve.digital')) {
|
||||
return $this->demo->response_with_no_content();
|
||||
}
|
||||
abort_if(is_demo_account('howdy@hi5ve.digital'), 204, 'Done.');
|
||||
|
||||
foreach ($request->input('items') as $item) {
|
||||
$this->filemanager->delete_item($item, $item['id']);
|
||||
@@ -117,9 +115,7 @@ class EditItemsController extends Controller
|
||||
*/
|
||||
public function move(MoveItemRequest $request)
|
||||
{
|
||||
if (is_demo_account('howdy@hi5ve.digital')) {
|
||||
return $this->demo->response_with_no_content();
|
||||
}
|
||||
abort_if(is_demo_account('howdy@hi5ve.digital'), 204, 'Done.');
|
||||
|
||||
$this->filemanager->move($request, $request->to_id);
|
||||
|
||||
|
||||
@@ -12,10 +12,7 @@ use Illuminate\Contracts\Routing\ResponseFactory;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use Illuminate\Support\Facades\Notification;
|
||||
use Illuminate\Support\Str;
|
||||
use Validator;
|
||||
|
||||
class ShareController extends Controller
|
||||
@@ -44,7 +41,7 @@ class ShareController extends Controller
|
||||
{
|
||||
// Create shared options
|
||||
$shared = Share::create([
|
||||
'password' => $request->has('password') ? Hash::make($request->password) : null,
|
||||
'password' => $request->has('password') ? bcrypt($request->password) : null,
|
||||
'type' => $request->type === 'folder' ? 'folder' : 'file',
|
||||
'is_protected' => $request->isPassword,
|
||||
'permission' => $request->permission ?? null,
|
||||
@@ -87,7 +84,7 @@ class ShareController extends Controller
|
||||
'permission' => $request->permission,
|
||||
'is_protected' => $request->protected,
|
||||
'expire_in' => $request->expiration,
|
||||
'password' => $request->password ? Hash::make($request->password) : $shared->password,
|
||||
'password' => $request->password ? bcrypt($request->password) : $shared->password,
|
||||
]);
|
||||
|
||||
// Return shared record
|
||||
|
||||
@@ -43,9 +43,7 @@ class TrashController extends Controller
|
||||
// Get user id
|
||||
$user_id = Auth::id();
|
||||
|
||||
if (is_demo($user_id)) {
|
||||
return $this->demo->response_with_no_content();
|
||||
}
|
||||
abort_if(is_demo_account('howdy@hi5ve.digital'), 204, 'Done.');
|
||||
|
||||
foreach ($request->input('items') as $restore) {
|
||||
|
||||
@@ -96,9 +94,7 @@ class TrashController extends Controller
|
||||
// Get user id
|
||||
$user_id = Auth::id();
|
||||
|
||||
if (is_demo($user_id)) {
|
||||
return $this->demo->response_with_no_content();
|
||||
}
|
||||
abort_if(is_demo_account('howdy@hi5ve.digital'), 204, 'Done.');
|
||||
|
||||
// Get files and folders
|
||||
$folders = Folder::onlyTrashed()->where('user_id', $user_id)->get();
|
||||
|
||||
@@ -121,9 +121,8 @@ class ManipulateShareItemsController extends Controller
|
||||
*/
|
||||
public function delete_item(DeleteItemRequest $request, Share $shared)
|
||||
{
|
||||
if (is_demo_account($shared->user->email)) {
|
||||
return $this->demo->response_with_no_content();
|
||||
}
|
||||
abort_if(is_demo_account($shared->user->email), 204, 'Done.');
|
||||
|
||||
|
||||
// Check ability to access protected share record
|
||||
$this->helper->check_protected_share_record($shared);
|
||||
@@ -195,9 +194,7 @@ class ManipulateShareItemsController extends Controller
|
||||
*/
|
||||
public function move(MoveItemRequest $request, Share $shared)
|
||||
{
|
||||
if (is_demo_account($shared->user->email)) {
|
||||
return $this->demo->response_with_no_content();
|
||||
}
|
||||
abort_if(is_demo_account($shared->user->email), 204, 'Done.');
|
||||
|
||||
// Check ability to access protected share record
|
||||
$this->helper->check_protected_share_record($shared);
|
||||
|
||||
@@ -3,8 +3,6 @@
|
||||
namespace App\Http\Controllers\User;
|
||||
|
||||
use App\Http\Requests\User\UpdateUserPasswordRequest;
|
||||
use App\Models\File;
|
||||
use App\Models\Folder;
|
||||
use App\Http\Resources\InvoiceCollection;
|
||||
use App\Http\Resources\StorageDetailResource;
|
||||
use App\Http\Resources\UserResource;
|
||||
@@ -14,10 +12,7 @@ use Illuminate\Contracts\Routing\ResponseFactory;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use Illuminate\Http\Request;
|
||||
use ByteUnits\Metric;
|
||||
use App\Models\User;
|
||||
|
||||
class AccountController extends Controller
|
||||
{
|
||||
@@ -88,9 +83,7 @@ class AccountController extends Controller
|
||||
$user = Auth::user();
|
||||
|
||||
// Check if is demo
|
||||
if (is_demo($user->id)) {
|
||||
return $this->demo->response_with_no_content();
|
||||
}
|
||||
abort_if(is_demo_account('howdy@hi5ve.digital'), 204, 'Done.');
|
||||
|
||||
// Update avatar
|
||||
if ($request->hasFile('avatar')) {
|
||||
@@ -123,12 +116,11 @@ class AccountController extends Controller
|
||||
// Get user
|
||||
$user = Auth::user();
|
||||
|
||||
if (is_demo($user->id)) {
|
||||
return $this->demo->response_with_no_content();
|
||||
}
|
||||
// Check if is demo
|
||||
abort_if(is_demo_account('howdy@hi5ve.digital'), 204, 'Done.');
|
||||
|
||||
// Change and store new password
|
||||
$user->password = Hash::make($request->input('password'));
|
||||
$user->password = bcrypt($request->input('password'));
|
||||
$user->save();
|
||||
|
||||
return response('Changed!', 204);
|
||||
|
||||
@@ -97,9 +97,7 @@ class PaymentMethodsController extends Controller
|
||||
$user = Auth::user();
|
||||
|
||||
// Check if is demo
|
||||
if (is_demo($user->id)) {
|
||||
return $this->demo->response_with_no_content();
|
||||
}
|
||||
abort_if(is_demo_account('howdy@hi5ve.digital'), 204, 'Done.');
|
||||
|
||||
// Update DefaultPayment Method
|
||||
$user->updateDefaultPaymentMethod($id);
|
||||
@@ -147,9 +145,7 @@ class PaymentMethodsController extends Controller
|
||||
$user = Auth::user();
|
||||
|
||||
// Check if is demo
|
||||
if (is_demo($user->id)) {
|
||||
return $this->demo->response_with_no_content();
|
||||
}
|
||||
abort_if(is_demo_account('howdy@hi5ve.digital'), 204, 'Done.');
|
||||
|
||||
// Get payment method
|
||||
$paymentMethod = $user->findPaymentMethod($id);
|
||||
|
||||
@@ -1,26 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Closure;
|
||||
use Illuminate\Support\Facades\Gate;
|
||||
|
||||
class AdminCheck
|
||||
{
|
||||
/**
|
||||
* Handle an incoming request.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \Closure $next
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle($request, Closure $next)
|
||||
{
|
||||
// Check if user have access to administration settings
|
||||
if ( ! Gate::allows('admin-settings')) {
|
||||
abort(403, 'You don\'t have access for this operation!');
|
||||
}
|
||||
|
||||
return $next($request);
|
||||
}
|
||||
}
|
||||
@@ -1,30 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Closure;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
class CookieAuth
|
||||
{
|
||||
/**
|
||||
* Handle an incoming request.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \Closure $next
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle($request, Closure $next)
|
||||
{
|
||||
if (!$request->bearerToken()) {
|
||||
if ($request->hasCookie('access_token')) {
|
||||
|
||||
$access_token = $request->cookie('access_token');
|
||||
|
||||
$request->headers->add(['Authorization' => 'Bearer ' . $access_token]);
|
||||
|
||||
}
|
||||
}
|
||||
return $next($request);
|
||||
}
|
||||
}
|
||||
@@ -151,7 +151,7 @@ function get_invoice_number()
|
||||
$invoices = \App\Invoice::all();
|
||||
|
||||
if ($invoices->isEmpty()) {
|
||||
return Carbon::now()->year . '001';
|
||||
return now()->year . '001';
|
||||
} else {
|
||||
return (int)$invoices->last()->order + 1;
|
||||
}
|
||||
@@ -589,11 +589,10 @@ function get_image_meta_data($file)
|
||||
*/
|
||||
function get_default_language_strings()
|
||||
{
|
||||
$license = get_setting('license') ?? 'extended';
|
||||
|
||||
return collect(
|
||||
config('language_strings.' . strtolower($license))
|
||||
);
|
||||
return collect([
|
||||
config("language-strings.extended"),
|
||||
config("language-strings.regular")
|
||||
])->collapse();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -168,7 +168,7 @@ class User extends Authenticatable
|
||||
*/
|
||||
public function record_upload($file_size)
|
||||
{
|
||||
$now = Carbon::now();
|
||||
$now = now();
|
||||
|
||||
$record = Traffic::whereYear('created_at', '=', $now->year)
|
||||
->whereMonth('created_at', '=', $now->month)
|
||||
@@ -188,7 +188,7 @@ class User extends Authenticatable
|
||||
*/
|
||||
public function record_download($file_size)
|
||||
{
|
||||
$now = Carbon::now();
|
||||
$now = now();
|
||||
|
||||
$record = Traffic::whereYear('created_at', '=', $now->year)
|
||||
->whereMonth('created_at', '=', $now->month)
|
||||
|
||||
@@ -39,8 +39,8 @@ class DemoService
|
||||
'items' => '0',
|
||||
'color' => isset($request->icon['color']) ? $request->icon['color'] : null,
|
||||
'emoji' => isset($request->icon['emoji']) ? $request->icon['emoji'] : null,
|
||||
'updated_at' => Carbon::now()->format('j M Y \a\t H:i'),
|
||||
'created_at' => Carbon::now()->format('j M Y \a\t H:i'),
|
||||
'updated_at' => now()->format('j M Y \a\t H:i'),
|
||||
'created_at' => now()->format('j M Y \a\t H:i'),
|
||||
];
|
||||
}
|
||||
|
||||
@@ -111,24 +111,15 @@ class DemoService
|
||||
'type' => $filetype,
|
||||
'file_url' => 'https://vuefilemanager.hi5ve.digital/assets/vue-file-manager-preview.jpg',
|
||||
'author' => $request->user() ? 'user' : 'visitor',
|
||||
'created_at' => Carbon::now()->format('j M Y \a\t H:i'),
|
||||
'updated_at' => Carbon::now()->format('j M Y \a\t H:i'),
|
||||
'created_at' => now()->format('j M Y \a\t H:i'),
|
||||
'updated_at' => now()->format('j M Y \a\t H:i'),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Return 204 status
|
||||
*
|
||||
* @return ResponseFactory|\Illuminate\Http\Response
|
||||
*/
|
||||
function response_with_no_content()
|
||||
{
|
||||
return response('Done!', 204);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return 204 status
|
||||
*
|
||||
* @param $user
|
||||
* @return ResponseFactory|\Illuminate\Http\Response
|
||||
*/
|
||||
function favourites($user)
|
||||
|
||||
@@ -17,7 +17,7 @@ class SchedulerService
|
||||
*/
|
||||
public function delete_old_zips(): void
|
||||
{
|
||||
Zip::where('created_at', '<=', Carbon::now()->subDay()->toDateTimeString())
|
||||
Zip::where('created_at', '<=', now()->subDay()->toDateTimeString())
|
||||
->get()
|
||||
->each(function ($zip) {
|
||||
|
||||
@@ -42,7 +42,7 @@ class SchedulerService
|
||||
$created_at = Carbon::parse($share->created_at);
|
||||
|
||||
// If time was over, then delete share record
|
||||
if ($created_at->diffInHours(Carbon::now()) >= $share->expire_in) {
|
||||
if ($created_at->diffInHours(now()) >= $share->expire_in) {
|
||||
$share->delete();
|
||||
}
|
||||
});
|
||||
@@ -69,7 +69,7 @@ class SchedulerService
|
||||
|
||||
// Get diffInHours
|
||||
$diff = Carbon::parse($last_modified)
|
||||
->diffInHours(Carbon::now());
|
||||
->diffInHours(now());
|
||||
|
||||
// Delete if file is in local storage more than 24 hours
|
||||
if ($diff >= 24) {
|
||||
|
||||
@@ -30,7 +30,7 @@ class ShareFactory extends Factory
|
||||
'type' => $this->faker->randomElement(['file', 'folder']),
|
||||
'permission' => $this->faker->randomElement(['visitor', 'editor']),
|
||||
'is_protected' => $this->faker->boolean(20),
|
||||
'password' => \Hash::make('secret'),
|
||||
'password' => bcrypt('secret'),
|
||||
'expire_in' => $this->faker->randomElement([1, 6, 12, 24]),
|
||||
];
|
||||
}
|
||||
|
||||
@@ -4,7 +4,6 @@ namespace Database\Factories;
|
||||
|
||||
use App\Models\User;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class UserFactory extends Factory
|
||||
@@ -29,7 +28,7 @@ class UserFactory extends Factory
|
||||
),
|
||||
'email' => $this->faker->unique()->safeEmail,
|
||||
'email_verified_at' => now(),
|
||||
'password' => Hash::make('secret'),
|
||||
'password' => bcrypt('secret'),
|
||||
'remember_token' => Str::random(10),
|
||||
'created_at' => $this->faker->dateTimeBetween(
|
||||
$startDate = '-36 months', $endDate = 'now', $timezone = null
|
||||
|
||||
@@ -32,7 +32,7 @@ class SchedulerTest extends TestCase
|
||||
$share = Share::factory(Share::class)
|
||||
->create([
|
||||
'expire_in' => 24,
|
||||
'created_at' => Carbon::now()->subDay(),
|
||||
'created_at' => now()->subDay(),
|
||||
]);
|
||||
|
||||
$this->scheduler->delete_expired_shared_links();
|
||||
@@ -58,7 +58,7 @@ class SchedulerTest extends TestCase
|
||||
|
||||
$zip = Zip::factory(Zip::class)->create([
|
||||
'basename' => 'EHWKcuvKzA4Gv29v-archive.zip',
|
||||
'created_at' => Carbon::now()->subDay(),
|
||||
'created_at' => now()->subDay(),
|
||||
]);
|
||||
|
||||
$this->scheduler->delete_old_zips();
|
||||
|
||||
12
tests/Feature/External/SubscriptionTest.php
vendored
12
tests/Feature/External/SubscriptionTest.php
vendored
@@ -195,9 +195,9 @@ class SubscriptionTest extends TestCase
|
||||
"capacity" => 1000,
|
||||
"capacity_formatted" => "1TB",
|
||||
"slug" => "business-pack",
|
||||
"canceled_at" => format_date(Carbon::now(), '%d. %B. %Y'),
|
||||
"created_at" => format_date(Carbon::now(), '%d. %B. %Y'),
|
||||
"ends_at" => format_date(Carbon::now()->addMonth(), '%d. %B. %Y'),
|
||||
"canceled_at" => format_date(now(), '%d. %B. %Y'),
|
||||
"created_at" => format_date(now(), '%d. %B. %Y'),
|
||||
"ends_at" => format_date(now()->addMonth(), '%d. %B. %Y'),
|
||||
]
|
||||
]
|
||||
]);
|
||||
@@ -265,9 +265,9 @@ class SubscriptionTest extends TestCase
|
||||
"capacity" => 1000,
|
||||
"capacity_formatted" => "1TB",
|
||||
"slug" => "business-pack",
|
||||
"canceled_at" => format_date(Carbon::now(), '%d. %B. %Y'),
|
||||
"created_at" => format_date(Carbon::now(), '%d. %B. %Y'),
|
||||
"ends_at" => format_date(Carbon::now()->addMonth(), '%d. %B. %Y'),
|
||||
"canceled_at" => format_date(now(), '%d. %B. %Y'),
|
||||
"created_at" => format_date(now(), '%d. %B. %Y'),
|
||||
"ends_at" => format_date(now()->addMonth(), '%d. %B. %Y'),
|
||||
]
|
||||
]
|
||||
]);
|
||||
|
||||
@@ -228,7 +228,7 @@ class BrowseTest extends TestCase
|
||||
"author" => "user",
|
||||
"type" => "file",
|
||||
'user_id' => $user->id,
|
||||
'created_at' => Carbon::now(),
|
||||
'created_at' => now(),
|
||||
]);
|
||||
|
||||
$this->travel(5)->minutes();
|
||||
@@ -242,7 +242,7 @@ class BrowseTest extends TestCase
|
||||
"author" => "user",
|
||||
"type" => "file",
|
||||
'user_id' => $user->id,
|
||||
'created_at' => Carbon::now(),
|
||||
'created_at' => now(),
|
||||
]);
|
||||
|
||||
$this->getJson("/api/browse/latest")
|
||||
@@ -339,7 +339,7 @@ class BrowseTest extends TestCase
|
||||
'name' => 'root',
|
||||
'user_id' => $user->id,
|
||||
"author" => "user",
|
||||
'deleted_at' => Carbon::now(),
|
||||
'deleted_at' => now(),
|
||||
]);
|
||||
|
||||
$file = File::factory(File::class)
|
||||
@@ -351,14 +351,14 @@ class BrowseTest extends TestCase
|
||||
"author" => "user",
|
||||
"type" => "file",
|
||||
'user_id' => $user->id,
|
||||
'deleted_at' => Carbon::now(),
|
||||
'deleted_at' => now(),
|
||||
]);
|
||||
|
||||
File::factory(File::class)
|
||||
->create([
|
||||
'folder_id' => $folder->id,
|
||||
'user_id' => $user->id,
|
||||
'deleted_at' => Carbon::now(),
|
||||
'deleted_at' => now(),
|
||||
]);
|
||||
|
||||
$this->getJson("/api/browse/trash")
|
||||
|
||||
@@ -35,7 +35,7 @@ class TrashTest extends TestCase
|
||||
|
||||
$attributes = [
|
||||
'user_id' => $user->id,
|
||||
'deleted_at' => Carbon::now(),
|
||||
'deleted_at' => now(),
|
||||
];
|
||||
|
||||
$folder = Folder::factory(Folder::class)
|
||||
|
||||
@@ -104,7 +104,7 @@ class VisitorBrowseTest extends TestCase
|
||||
'user_id' => $file->user_id,
|
||||
'type' => 'file',
|
||||
'is_protected' => true,
|
||||
'password' => Hash::make('secret'),
|
||||
'password' => bcrypt('secret'),
|
||||
]);
|
||||
|
||||
$this->postJson("/api/browse/authenticate/$share->token", [
|
||||
@@ -131,7 +131,7 @@ class VisitorBrowseTest extends TestCase
|
||||
'user_id' => $file->user_id,
|
||||
'type' => 'file',
|
||||
'is_protected' => true,
|
||||
'password' => Hash::make('secret'),
|
||||
'password' => bcrypt('secret'),
|
||||
]);
|
||||
|
||||
$this->postJson("/api/browse/authenticate/$share->token", [
|
||||
@@ -545,7 +545,7 @@ class VisitorBrowseTest extends TestCase
|
||||
'type' => 'folder',
|
||||
'permission' => 'editor',
|
||||
'is_protected' => $is_protected,
|
||||
'password' => Hash::make('secret'),
|
||||
'password' => bcrypt('secret'),
|
||||
]);
|
||||
|
||||
$folder_level_2 = Folder::factory(Folder::class)
|
||||
@@ -654,7 +654,7 @@ class VisitorBrowseTest extends TestCase
|
||||
'type' => 'folder',
|
||||
'permission' => 'editor',
|
||||
'is_protected' => $is_protected,
|
||||
'password' => Hash::make('secret'),
|
||||
'password' => bcrypt('secret'),
|
||||
]);
|
||||
|
||||
$file = File::factory(File::class)
|
||||
@@ -711,7 +711,7 @@ class VisitorBrowseTest extends TestCase
|
||||
'type' => 'folder',
|
||||
'permission' => 'editor',
|
||||
'is_protected' => $is_protected,
|
||||
'password' => Hash::make('secret'),
|
||||
'password' => bcrypt('secret'),
|
||||
]);
|
||||
|
||||
File::factory(File::class)
|
||||
@@ -765,7 +765,7 @@ class VisitorBrowseTest extends TestCase
|
||||
'type' => 'file',
|
||||
'permission' => 'editor',
|
||||
'is_protected' => $is_protected,
|
||||
'password' => Hash::make('secret'),
|
||||
'password' => bcrypt('secret'),
|
||||
]);
|
||||
|
||||
// Check shared item protected by password
|
||||
|
||||
Reference in New Issue
Block a user