diff --git a/.env.testing b/.env.testing new file mode 100644 index 00000000..5cb8ce06 --- /dev/null +++ b/.env.testing @@ -0,0 +1,48 @@ +APP_NAME=Laravel +APP_ENV=testing +APP_KEY=base64:47yorkyoH3qCrKKO4eG6LpZUogoTC51qey5vYq/O3AM= +APP_DEBUG=true +APP_URL=http://localhost + +LOG_CHANNEL=stack + +DB_CONNECTION=sqlite +DB_HOST=null +DB_PORT=null +DB_DATABASE=database/test.sqlite +DB_USERNAME=null +DB_PASSWORD=null + +BROADCAST_DRIVER=log +CACHE_DRIVER=file +SESSION_DRIVER=file +SESSION_LIFETIME=120 +SCOUT_DRIVER=tntsearch + +REDIS_HOST=127.0.0.1 +REDIS_PASSWORD=null +REDIS_PORT=6379 + +MAIL_MAILER=log +MAIL_HOST=smtp.mailtrap.io +MAIL_PORT=2525 +MAIL_USERNAME=null +MAIL_PASSWORD=null +MAIL_ENCRYPTION=null +MAIL_FROM_ADDRESS=null +MAIL_FROM_NAME="${APP_NAME}" + +AWS_ACCESS_KEY_ID= +AWS_SECRET_ACCESS_KEY= +AWS_DEFAULT_REGION=us-east-1 +AWS_BUCKET= + +PUSHER_APP_ID= +PUSHER_APP_KEY= +PUSHER_APP_SECRET= +PUSHER_APP_CLUSTER=mt1 + +MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}" +MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}" + +SANCTUM_STATEFUL_DOMAINS=localhost,127.0.0.1,127.0.0.1:8000,::1 diff --git a/app/Http/Kernel.php b/app/Http/Kernel.php index 91f97058..c4bb8a7c 100644 --- a/app/Http/Kernel.php +++ b/app/Http/Kernel.php @@ -2,11 +2,8 @@ namespace App\Http; -use App\Http\Middleware\AdminCheck; -use App\Http\Middleware\CookieAuth; -use App\Http\Middleware\LastCheck; -use App\Http\Middleware\SharedAuth; use Illuminate\Foundation\Http\Kernel as HttpKernel; +use Laravel\Sanctum\Http\Middleware\EnsureFrontendRequestsAreStateful; class Kernel extends HttpKernel { @@ -43,6 +40,7 @@ class Kernel extends HttpKernel ], 'api' => [ + EnsureFrontendRequestsAreStateful::class, \App\Http\Middleware\EncryptCookies::class, //'throttle:60,1', \Illuminate\Routing\Middleware\SubstituteBindings::class, @@ -57,39 +55,14 @@ class Kernel extends HttpKernel * @var array */ protected $routeMiddleware = [ - 'auth.master' => CookieAuth::class, - 'auth.shared' => SharedAuth::class, - 'auth.admin' => AdminCheck::class, - 'auth' => \App\Http\Middleware\Authenticate::class, - 'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class, - 'bindings' => \Illuminate\Routing\Middleware\SubstituteBindings::class, - 'cache.headers' => \Illuminate\Http\Middleware\SetCacheHeaders::class, - 'can' => \Illuminate\Auth\Middleware\Authorize::class, - 'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class, + 'auth' => \App\Http\Middleware\Authenticate::class, + 'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class, + 'cache.headers' => \Illuminate\Http\Middleware\SetCacheHeaders::class, + 'can' => \Illuminate\Auth\Middleware\Authorize::class, + 'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class, 'password.confirm' => \Illuminate\Auth\Middleware\RequirePassword::class, - 'signed' => \Illuminate\Routing\Middleware\ValidateSignature::class, - 'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class, - 'verified' => \Illuminate\Auth\Middleware\EnsureEmailIsVerified::class, - 'scopes' => \Laravel\Passport\Http\Middleware\CheckScopes::class, - 'scope' => \Laravel\Passport\Http\Middleware\CheckForAnyScope::class, - ]; - - /** - * The priority-sorted list of middleware. - * - * This forces non-global middleware to always be in the given order. - * - * @var array - */ - protected $middlewarePriority = [ - \Illuminate\Session\Middleware\StartSession::class, - \Illuminate\View\Middleware\ShareErrorsFromSession::class, - CookieAuth::class, - SharedAuth::class, - \App\Http\Middleware\Authenticate::class, - \Illuminate\Routing\Middleware\ThrottleRequests::class, - \Illuminate\Session\Middleware\AuthenticateSession::class, - \Illuminate\Routing\Middleware\SubstituteBindings::class, - \Illuminate\Auth\Middleware\Authorize::class, + 'signed' => \Illuminate\Routing\Middleware\ValidateSignature::class, + 'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class, + 'verified' => \Illuminate\Auth\Middleware\EnsureEmailIsVerified::class, ]; } diff --git a/database/migrations/2014_10_12_000000_create_users_table.php b/database/migrations/2014_10_12_000000_create_users_table.php index 286eeb4d..15f0c600 100644 --- a/database/migrations/2014_10_12_000000_create_users_table.php +++ b/database/migrations/2014_10_12_000000_create_users_table.php @@ -14,12 +14,13 @@ class CreateUsersTable extends Migration public function up() { Schema::create('users', function (Blueprint $table) { - $table->bigIncrements('id'); + $table->uuid('id'); + $table->enum('role', ['admin', 'user'])->default('user'); $table->string('name'); + $table->string('avatar')->nullable(); $table->string('email')->unique(); $table->timestamp('email_verified_at')->nullable(); $table->string('password'); - $table->string('avatar')->nullable(); $table->rememberToken(); $table->timestamps(); }); diff --git a/database/migrations/2016_06_01_000001_create_oauth_auth_codes_table.php b/database/migrations/2016_06_01_000001_create_oauth_auth_codes_table.php deleted file mode 100644 index 6c47d247..00000000 --- a/database/migrations/2016_06_01_000001_create_oauth_auth_codes_table.php +++ /dev/null @@ -1,35 +0,0 @@ -string('id', 100)->primary(); - $table->unsignedBigInteger('user_id')->index(); - $table->unsignedBigInteger('client_id'); - $table->text('scopes')->nullable(); - $table->boolean('revoked'); - $table->dateTime('expires_at')->nullable(); - }); - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::dropIfExists('oauth_auth_codes'); - } -} diff --git a/database/migrations/2016_06_01_000002_create_oauth_access_tokens_table.php b/database/migrations/2016_06_01_000002_create_oauth_access_tokens_table.php deleted file mode 100644 index 00f00633..00000000 --- a/database/migrations/2016_06_01_000002_create_oauth_access_tokens_table.php +++ /dev/null @@ -1,37 +0,0 @@ -string('id', 100)->primary(); - $table->unsignedBigInteger('user_id')->nullable()->index(); - $table->unsignedBigInteger('client_id'); - $table->string('name')->nullable(); - $table->text('scopes')->nullable(); - $table->boolean('revoked'); - $table->timestamps(); - $table->dateTime('expires_at')->nullable(); - }); - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::dropIfExists('oauth_access_tokens'); - } -} diff --git a/database/migrations/2016_06_01_000003_create_oauth_refresh_tokens_table.php b/database/migrations/2016_06_01_000003_create_oauth_refresh_tokens_table.php deleted file mode 100644 index 858d0f6d..00000000 --- a/database/migrations/2016_06_01_000003_create_oauth_refresh_tokens_table.php +++ /dev/null @@ -1,33 +0,0 @@ -string('id', 100)->primary(); - $table->string('access_token_id', 100); - $table->boolean('revoked'); - $table->dateTime('expires_at')->nullable(); - }); - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::dropIfExists('oauth_refresh_tokens'); - } -} diff --git a/database/migrations/2016_06_01_000004_create_oauth_clients_table.php b/database/migrations/2016_06_01_000004_create_oauth_clients_table.php deleted file mode 100644 index 1dc541a3..00000000 --- a/database/migrations/2016_06_01_000004_create_oauth_clients_table.php +++ /dev/null @@ -1,38 +0,0 @@ -bigIncrements('id'); - $table->unsignedBigInteger('user_id')->nullable()->index(); - $table->string('name'); - $table->string('secret', 100)->nullable(); - $table->text('redirect'); - $table->boolean('personal_access_client'); - $table->boolean('password_client'); - $table->boolean('revoked'); - $table->timestamps(); - }); - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::dropIfExists('oauth_clients'); - } -} diff --git a/database/migrations/2016_06_01_000005_create_oauth_personal_access_clients_table.php b/database/migrations/2016_06_01_000005_create_oauth_personal_access_clients_table.php deleted file mode 100644 index 4b56435c..00000000 --- a/database/migrations/2016_06_01_000005_create_oauth_personal_access_clients_table.php +++ /dev/null @@ -1,32 +0,0 @@ -bigIncrements('id'); - $table->unsignedBigInteger('client_id'); - $table->timestamps(); - }); - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::dropIfExists('oauth_personal_access_clients'); - } -} diff --git a/database/migrations/2019_05_03_000002_create_subscriptions_table.php b/database/migrations/2019_05_03_000002_create_subscriptions_table.php index 92ac046a..7bc324d7 100644 --- a/database/migrations/2019_05_03_000002_create_subscriptions_table.php +++ b/database/migrations/2019_05_03_000002_create_subscriptions_table.php @@ -15,7 +15,7 @@ class CreateSubscriptionsTable extends Migration { Schema::create('subscriptions', function (Blueprint $table) { $table->bigIncrements('id'); - $table->unsignedBigInteger('user_id'); + $table->uuid('user_id'); $table->string('name'); $table->string('stripe_id'); $table->string('stripe_status'); diff --git a/database/migrations/2019_08_15_171328_create_file_manager_folders.php b/database/migrations/2019_08_15_171328_create_file_manager_folders.php index a3dbdc89..75a11f18 100644 --- a/database/migrations/2019_08_15_171328_create_file_manager_folders.php +++ b/database/migrations/2019_08_15_171328_create_file_manager_folders.php @@ -13,15 +13,14 @@ class CreateFileManagerFolders extends Migration */ public function up() { - Schema::create('file_manager_folders', function (Blueprint $table) { - - $table->bigIncrements('id'); - $table->integer('unique_id'); - $table->integer('parent_id')->default(0); - - $table->text('name')->nullable(); - $table->text('type')->nullable(); - + Schema::create('folders', function (Blueprint $table) { + $table->uuid('id')->primary(); + $table->uuid('user_id'); + $table->uuid('parent_id'); + $table->text('name'); + $table->string('color')->nullable(); + $table->string('emoji')->nullable(); + $table->enum('user_scope', ['master', 'editor', 'visitor'])->default('master'); $table->softDeletes(); $table->timestamps(); }); diff --git a/database/migrations/2019_08_15_171345_create_file_manager_files.php b/database/migrations/2019_08_15_171345_create_file_manager_files.php index adfc7983..70c96e09 100644 --- a/database/migrations/2019_08_15_171345_create_file_manager_files.php +++ b/database/migrations/2019_08_15_171345_create_file_manager_files.php @@ -13,20 +13,21 @@ class CreateFileManagerFiles extends Migration */ public function up() { - Schema::create('file_manager_files', function (Blueprint $table) { - - $table->bigIncrements('id'); - $table->integer('unique_id'); - $table->integer('folder_id')->default(0); + Schema::create('files', function (Blueprint $table) { + $table->uuid('id')->primary(); + $table->uuid('user_id'); + $table->uuid('folder_id'); $table->text('thumbnail')->nullable(); - $table->text('name')->nullable(); - $table->text('basename')->nullable(); + $table->text('name'); + $table->text('basename'); $table->text('mimetype')->nullable(); - $table->text('filesize')->nullable(); + $table->text('filesize'); $table->text('type')->nullable(); + $table->longText('metadata')->nullable(); + $table->enum('user_scope', ['master', 'editor', 'visitor'])->default('master'); $table->softDeletes(); $table->timestamps(); diff --git a/database/migrations/2020_03_03_065147_add_user_id_to_file_manager_files_table.php b/database/migrations/2020_03_03_065147_add_user_id_to_file_manager_files_table.php deleted file mode 100644 index afce30e7..00000000 --- a/database/migrations/2020_03_03_065147_add_user_id_to_file_manager_files_table.php +++ /dev/null @@ -1,32 +0,0 @@ -bigInteger('user_id')->after('id')->nullable(); - }); - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::table('file_manager_files', function (Blueprint $table) { - // - }); - } -} diff --git a/database/migrations/2020_03_03_065155_add_user_id_to_file_manager_folders_table.php b/database/migrations/2020_03_03_065155_add_user_id_to_file_manager_folders_table.php deleted file mode 100644 index 022113c2..00000000 --- a/database/migrations/2020_03_03_065155_add_user_id_to_file_manager_folders_table.php +++ /dev/null @@ -1,32 +0,0 @@ -bigInteger('user_id')->after('id')->nullable(); - }); - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::table('file_manager_folders', function (Blueprint $table) { - // - }); - } -} diff --git a/database/migrations/2020_03_03_070319_create_favourites_folders_table.php b/database/migrations/2020_03_03_070319_create_favourites_folders_table.php index fe50e6c3..eb3f275b 100644 --- a/database/migrations/2020_03_03_070319_create_favourites_folders_table.php +++ b/database/migrations/2020_03_03_070319_create_favourites_folders_table.php @@ -14,8 +14,8 @@ class CreateFavouritesFoldersTable extends Migration public function up() { Schema::create('favourite_folder', function (Blueprint $table) { - $table->bigInteger('user_id'); - $table->bigInteger('folder_unique_id'); + $table->uuid('user_id'); + $table->uuid('folder_id'); }); } diff --git a/database/migrations/2020_04_20_071047_create_shares_table.php b/database/migrations/2020_04_20_071047_create_shares_table.php index ba542743..713586e2 100644 --- a/database/migrations/2020_04_20_071047_create_shares_table.php +++ b/database/migrations/2020_04_20_071047_create_shares_table.php @@ -14,14 +14,15 @@ class CreateSharesTable extends Migration public function up() { Schema::create('shares', function (Blueprint $table) { - $table->bigIncrements('id'); - $table->bigInteger('user_id'); + $table->uuid('id')->primary(); + $table->uuid('user_id'); $table->string('token', 16)->unique(); - $table->bigInteger('item_id'); - $table->enum('type', ['file', 'files', 'folder']); + $table->uuid('item_id'); + $table->enum('type', ['file', 'folder']); $table->enum('permission', ['visitor', 'editor'])->nullable(); - $table->boolean('protected'); + $table->boolean('is_protected')->default(0); $table->string('password')->nullable(); + $table->integer('expire_in')->nullable(); $table->timestamps(); }); } diff --git a/database/migrations/2020_04_24_055817_add_user_scope_to_file_manager_files_table.php b/database/migrations/2020_04_24_055817_add_user_scope_to_file_manager_files_table.php deleted file mode 100644 index ae0b3772..00000000 --- a/database/migrations/2020_04_24_055817_add_user_scope_to_file_manager_files_table.php +++ /dev/null @@ -1,32 +0,0 @@ -string('user_scope')->after('type')->default('master'); - }); - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::table('file_manager_files', function (Blueprint $table) { - // - }); - } -} diff --git a/database/migrations/2020_04_24_080943_add_user_scope_to_file_manager_folders_table.php b/database/migrations/2020_04_24_080943_add_user_scope_to_file_manager_folders_table.php deleted file mode 100644 index 99eb3230..00000000 --- a/database/migrations/2020_04_24_080943_add_user_scope_to_file_manager_folders_table.php +++ /dev/null @@ -1,32 +0,0 @@ -string('user_scope')->after('type')->default('master'); - }); - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::table('file_manager_folders', function (Blueprint $table) { - // - }); - } -} diff --git a/database/migrations/2020_05_26_062714_add_role_to_users_table.php b/database/migrations/2020_05_26_062714_add_role_to_users_table.php deleted file mode 100644 index cdc03d9f..00000000 --- a/database/migrations/2020_05_26_062714_add_role_to_users_table.php +++ /dev/null @@ -1,32 +0,0 @@ -enum('role', ['admin', 'user'])->default('user')->after('id'); - }); - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::table('users', function (Blueprint $table) { - // - }); - } -} diff --git a/database/migrations/2020_05_26_092649_create_user_settings_table.php b/database/migrations/2020_05_26_092649_create_user_settings_table.php index 0cdbadf0..ab4cb864 100644 --- a/database/migrations/2020_05_26_092649_create_user_settings_table.php +++ b/database/migrations/2020_05_26_092649_create_user_settings_table.php @@ -14,9 +14,16 @@ class CreateUserSettingsTable extends Migration public function up() { Schema::create('user_settings', function (Blueprint $table) { - $table->bigIncrements('id'); - $table->integer('user_id'); + $table->uuid('user_id'); $table->integer('storage_capacity')->default(5); + $table->text('name')->nullable(); + $table->text('address')->nullable(); + $table->text('state')->nullable(); + $table->text('city')->nullable(); + $table->text('postal_code')->nullable(); + $table->text('country')->nullable(); + $table->text('phone_number')->nullable(); + $table->decimal('timezone', 10, 1)->nullable(); }); } diff --git a/database/migrations/2020_06_02_073651_add_attributes_to_user_settings_table.php b/database/migrations/2020_06_02_073651_add_attributes_to_user_settings_table.php deleted file mode 100644 index 5e4fd8b8..00000000 --- a/database/migrations/2020_06_02_073651_add_attributes_to_user_settings_table.php +++ /dev/null @@ -1,44 +0,0 @@ -text('billing_name')->nullable(); - $table->text('billing_address')->nullable(); - $table->text('billing_state')->nullable(); - $table->text('billing_city')->nullable(); - $table->text('billing_postal_code')->nullable(); - $table->text('billing_country')->nullable(); - $table->text('billing_phone_number')->nullable(); - }); - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::table('user_settings', function (Blueprint $table) { - $table->dropColumn('billing_name'); - $table->dropColumn('billing_address'); - $table->dropColumn('billing_state'); - $table->dropColumn('billing_city'); - $table->dropColumn('billing_postal_code'); - $table->dropColumn('billing_country'); - $table->dropColumn('billing_phone_number'); - }); - } -} diff --git a/database/migrations/2020_06_25_142635_create_settings_table.php b/database/migrations/2020_06_25_142635_create_settings_table.php index e9b8d2a1..44fb4ba8 100644 --- a/database/migrations/2020_06_25_142635_create_settings_table.php +++ b/database/migrations/2020_06_25_142635_create_settings_table.php @@ -14,7 +14,6 @@ class CreateSettingsTable extends Migration public function up() { Schema::create('settings', function (Blueprint $table) { - $table->bigIncrements('id'); $table->string('name')->unique(); $table->longText('value')->nullable(); }); diff --git a/database/migrations/2020_07_08_080255_create_pages_table.php b/database/migrations/2020_07_08_080255_create_pages_table.php index dbd3af42..639adfea 100644 --- a/database/migrations/2020_07_08_080255_create_pages_table.php +++ b/database/migrations/2020_07_08_080255_create_pages_table.php @@ -14,10 +14,9 @@ class CreatePagesTable extends Migration public function up() { Schema::create('pages', function (Blueprint $table) { - $table->id(); - $table->boolean('visibility'); - $table->string('title'); $table->string('slug'); + $table->string('title'); + $table->boolean('visibility'); $table->longText('content'); }); } diff --git a/database/migrations/2020_08_25_143449_add_expiration_at_attribute_to_shares_table.php b/database/migrations/2020_08_25_143449_add_expiration_at_attribute_to_shares_table.php deleted file mode 100644 index a018f5de..00000000 --- a/database/migrations/2020_08_25_143449_add_expiration_at_attribute_to_shares_table.php +++ /dev/null @@ -1,32 +0,0 @@ -integer('expire_in')->after('password')->nullable(); - }); - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::table('shares', function (Blueprint $table) { - // - }); - } -} diff --git a/database/migrations/2020_09_04_085714_add_exif_data_to_file_manager_files_table.php b/database/migrations/2020_09_04_085714_add_exif_data_to_file_manager_files_table.php deleted file mode 100644 index 41f2e956..00000000 --- a/database/migrations/2020_09_04_085714_add_exif_data_to_file_manager_files_table.php +++ /dev/null @@ -1,32 +0,0 @@ -longText('metadata')->after('type')->nullable(); - }); - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::table('file_manager_files', function (Blueprint $table) { - // - }); - } -} diff --git a/database/migrations/2020_11_22_101014_create_traffic_table.php b/database/migrations/2020_11_22_101014_create_traffic_table.php index 9055d476..19a128eb 100644 --- a/database/migrations/2020_11_22_101014_create_traffic_table.php +++ b/database/migrations/2020_11_22_101014_create_traffic_table.php @@ -14,8 +14,8 @@ class CreateTrafficTable extends Migration public function up() { Schema::create('traffic', function (Blueprint $table) { - $table->bigIncrements('id'); - $table->bigInteger('user_id'); + $table->uuid('id'); + $table->uuid('user_id'); $table->bigInteger('upload')->default(0); $table->bigInteger('download')->default(0); $table->timestamps(); diff --git a/database/migrations/2020_12_13_155309_create_zips_table.php b/database/migrations/2020_12_13_155309_create_zips_table.php index 4e81c78e..1c30e965 100644 --- a/database/migrations/2020_12_13_155309_create_zips_table.php +++ b/database/migrations/2020_12_13_155309_create_zips_table.php @@ -15,7 +15,7 @@ class CreateZipsTable extends Migration { Schema::create('zips', function (Blueprint $table) { $table->uuid('id')->primary(); - $table->bigInteger('user_id'); + $table->uuid('user_id'); $table->string('shared_token')->nullable(); $table->text('basename'); $table->timestamps(); diff --git a/database/migrations/2021_01_03_164426_add_timezone_to_user_settings_table.php b/database/migrations/2021_01_03_164426_add_timezone_to_user_settings_table.php deleted file mode 100644 index b9782a54..00000000 --- a/database/migrations/2021_01_03_164426_add_timezone_to_user_settings_table.php +++ /dev/null @@ -1,32 +0,0 @@ -decimal('timezone', 10, 1)->after('billing_phone_number')->nullable(); - }); - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::table('user_settings', function (Blueprint $table) { - // - }); - } -} diff --git a/database/migrations/2021_01_13_162117_add_folder_icon_options_to_file_manager_folders_table.php b/database/migrations/2021_01_13_162117_add_folder_icon_options_to_file_manager_folders_table.php deleted file mode 100644 index 89bee859..00000000 --- a/database/migrations/2021_01_13_162117_add_folder_icon_options_to_file_manager_folders_table.php +++ /dev/null @@ -1,33 +0,0 @@ -string('icon_color')->after('user_scope')->nullable(); - $table->string('icon_emoji')->after('icon_color')->nullable(); - }); - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::table('file_manager_folders', function (Blueprint $table) { - // - }); - } -}