From c1a58e29dd4733b1a81069f2c08ede59f6d42fe0 Mon Sep 17 00:00:00 2001 From: Refringe Date: Thu, 4 Jul 2024 22:10:48 -0400 Subject: [PATCH 01/20] Multiple Mod Authors The mod-to-user relationship has been modified to be a many-to-many relationship. Mods can now have multiple authors, and an author can have multiple mods. --- app/Http/Controllers/ModController.php | 2 +- app/Http/Resources/Api/V0/ModResource.php | 29 +++++++++++-------- app/Http/Resources/ModResource.php | 1 - app/Models/License.php | 5 ---- app/Models/Mod.php | 28 ++++++++++-------- app/Models/ModVersion.php | 9 ------ app/Models/SptVersion.php | 5 ---- app/Models/User.php | 12 ++------ app/Models/UserRole.php | 7 ----- app/Providers/AppServiceProvider.php | 4 +++ app/View/Components/ModListSection.php | 26 ++++++++--------- database/factories/ModFactory.php | 3 +- .../2024_05_15_022710_create_mods_table.php | 5 ---- ...24_05_15_023706_create_mod_users_table.php | 29 +++++++++++++++++++ database/seeders/DatabaseSeeder.php | 7 ++++- resources/views/components/mod-list.blade.php | 2 +- resources/views/mod/show.blade.php | 2 +- 17 files changed, 92 insertions(+), 84 deletions(-) create mode 100644 database/migrations/2024_05_15_023706_create_mod_users_table.php diff --git a/app/Http/Controllers/ModController.php b/app/Http/Controllers/ModController.php index 1cad7c3..3f29240 100644 --- a/app/Http/Controllers/ModController.php +++ b/app/Http/Controllers/ModController.php @@ -30,7 +30,7 @@ class ModController extends Controller $mod = Mod::select() ->withLatestSptVersion() ->withTotalDownloads() - ->with('user:id,name') + ->with('users:id,name') ->with('license:id,name,link') ->find($modId); diff --git a/app/Http/Resources/Api/V0/ModResource.php b/app/Http/Resources/Api/V0/ModResource.php index e73ff0c..746671b 100644 --- a/app/Http/Resources/Api/V0/ModResource.php +++ b/app/Http/Resources/Api/V0/ModResource.php @@ -20,22 +20,27 @@ class ModResource extends JsonResource 'attributes' => [ 'name' => $this->name, 'slug' => $this->slug, + 'teaser' => $this->teaser, 'description' => $this->when( $request->routeIs('api.v0.mods.show'), $this->description ), - 'source_code_link' => $this->source_code_link, - 'user_id' => $this->user_id, 'license_id' => $this->license_id, + 'source_code_link' => $this->source_code_link, + 'featured' => $this->featured, + 'contains_ai_content' => $this->contains_ai_content, + 'contains_ads' => $this->contains_ads, 'created_at' => $this->created_at, + 'updated_at' => $this->updated_at, ], 'relationships' => [ - 'user' => [ - 'data' => [ + 'users' => [ + 'data' => $this->users->map(fn ($user) => [ 'type' => 'user', - 'id' => $this->user_id, - ], - // TODO: Provide 'links.self' to user profile: + 'id' => $user->id, + ])->toArray(), + + // TODO: Provide 'links.self' to user profile //'links' => ['self' => '#'], ], 'license' => [ @@ -45,11 +50,11 @@ class ModResource extends JsonResource ], ], ], - 'included' => [ - new UserResource($this->user), - // TODO: Provide 'included' data for attached 'license': - //new LicenseResource($this->license), - ], + 'included' => $this->users->map(fn ($user) => new UserResource($user)), + + // TODO: Provide 'included' data for attached 'license': + //new LicenseResource($this->license) + 'links' => [ 'self' => route('mod.show', [ 'mod' => $this->id, diff --git a/app/Http/Resources/ModResource.php b/app/Http/Resources/ModResource.php index f61b2c6..0ab080b 100644 --- a/app/Http/Resources/ModResource.php +++ b/app/Http/Resources/ModResource.php @@ -16,7 +16,6 @@ class ModResource extends JsonResource 'slug' => $this->slug, 'description' => $this->description, 'source_code_link' => $this->source_code_link, - 'user_id' => $this->user_id, 'license_id' => $this->license_id, 'license' => new LicenseResource($this->whenLoaded('license')), 'created_at' => $this->created_at, diff --git a/app/Models/License.php b/app/Models/License.php index 2c8363d..d67c71e 100644 --- a/app/Models/License.php +++ b/app/Models/License.php @@ -11,11 +11,6 @@ class License extends Model { use HasFactory, SoftDeletes; - protected $fillable = [ - 'name', - 'link', - ]; - public function mods(): HasMany { return $this->hasMany(Mod::class); diff --git a/app/Models/Mod.php b/app/Models/Mod.php index a6344be..97eed4b 100644 --- a/app/Models/Mod.php +++ b/app/Models/Mod.php @@ -7,6 +7,7 @@ use Illuminate\Database\Eloquent\Casts\Attribute; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Relations\BelongsTo; +use Illuminate\Database\Eloquent\Relations\BelongsToMany; use Illuminate\Database\Eloquent\Relations\HasMany; use Illuminate\Database\Eloquent\SoftDeletes; use Illuminate\Support\Facades\Storage; @@ -20,25 +21,18 @@ class Mod extends Model { use HasFactory, Searchable, SoftDeletes; - protected $fillable = [ - 'user_id', - 'name', - 'slug', - 'teaser', - 'description', - 'license_id', - 'source_code_link', - ]; - protected static function booted(): void { // Apply the global scope to exclude disabled mods. static::addGlobalScope(new DisabledScope); } - public function user(): BelongsTo + /** + * The users that belong to the mod. + */ + public function users(): BelongsToMany { - return $this->belongsTo(User::class); + return $this->belongsToMany(User::class); } public function license(): BelongsTo @@ -155,6 +149,16 @@ class Mod extends Model }; } + protected function casts(): array + { + return [ + 'featured' => 'boolean', + 'contains_ai_content' => 'boolean', + 'contains_ads' => 'boolean', + 'disabled' => 'boolean', + ]; + } + /** * Ensure the slug is always lower case when retrieved and slugified when saved. */ diff --git a/app/Models/ModVersion.php b/app/Models/ModVersion.php index 3ec3b8f..a167039 100644 --- a/app/Models/ModVersion.php +++ b/app/Models/ModVersion.php @@ -12,15 +12,6 @@ class ModVersion extends Model { use HasFactory, SoftDeletes; - protected $fillable = [ - 'mod_id', - 'version', - 'description', - 'spt_version_id', - 'virus_total_link', - 'downloads', - ]; - protected static function booted(): void { static::addGlobalScope(new DisabledScope); diff --git a/app/Models/SptVersion.php b/app/Models/SptVersion.php index f261e43..518a308 100644 --- a/app/Models/SptVersion.php +++ b/app/Models/SptVersion.php @@ -11,11 +11,6 @@ class SptVersion extends Model { use HasFactory, SoftDeletes; - protected $fillable = [ - 'version', - 'color_class', - ]; - public function modVersions(): HasMany { return $this->hasMany(ModVersion::class); diff --git a/app/Models/User.php b/app/Models/User.php index 841a3c8..248fd04 100644 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -5,7 +5,7 @@ namespace App\Models; use Illuminate\Contracts\Auth\MustVerifyEmail; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Relations\BelongsTo; -use Illuminate\Database\Eloquent\Relations\HasMany; +use Illuminate\Database\Eloquent\Relations\BelongsToMany; use Illuminate\Foundation\Auth\User as Authenticatable; use Illuminate\Notifications\Notifiable; use Illuminate\Support\Str; @@ -25,12 +25,6 @@ class User extends Authenticatable implements MustVerifyEmail use Searchable; use TwoFactorAuthenticatable; - protected $fillable = [ - 'name', - 'email', - 'password', - ]; - protected $hidden = [ 'password', 'remember_token', @@ -42,9 +36,9 @@ class User extends Authenticatable implements MustVerifyEmail 'profile_photo_url', ]; - public function mods(): HasMany + public function mods(): BelongsToMany { - return $this->hasMany(Mod::class); + return $this->belongsToMany(Mod::class); } public function toSearchableArray(): array diff --git a/app/Models/UserRole.php b/app/Models/UserRole.php index b496c20..df600ef 100644 --- a/app/Models/UserRole.php +++ b/app/Models/UserRole.php @@ -10,13 +10,6 @@ class UserRole extends Model { use HasFactory; - protected $fillable = [ - 'name', - 'short_name', - 'description', - 'color_class', - ]; - public function users(): HasMany { return $this->hasMany(User::class); diff --git a/app/Providers/AppServiceProvider.php b/app/Providers/AppServiceProvider.php index 9d28d7a..dd2a10a 100644 --- a/app/Providers/AppServiceProvider.php +++ b/app/Providers/AppServiceProvider.php @@ -3,6 +3,7 @@ namespace App\Providers; use App\Models\User; +use Illuminate\Database\Eloquent\Model; use Illuminate\Support\Facades\Gate; use Illuminate\Support\ServiceProvider; @@ -21,6 +22,9 @@ class AppServiceProvider extends ServiceProvider */ public function boot(): void { + // Allow mass assignment for all models. Be careful! + Model::unguard(); + // This gate determines who can access the Pulse dashboard. Gate::define('viewPulse', function (User $user) { return $user->isAdmin(); diff --git a/app/View/Components/ModListSection.php b/app/View/Components/ModListSection.php index 2332a9a..82335a7 100644 --- a/app/View/Components/ModListSection.php +++ b/app/View/Components/ModListSection.php @@ -24,10 +24,10 @@ class ModListSection extends Component private function fetchFeaturedMods(): Collection { - return Mod::select(['id', 'user_id', 'name', 'slug', 'teaser', 'thumbnail', 'featured']) + return Mod::select(['id', 'name', 'slug', 'teaser', 'thumbnail', 'featured']) ->withLatestSptVersion() ->withTotalDownloads() - ->with('user:id,name') + ->with('users:id,name') ->where('featured', true) ->latest() ->limit(6) @@ -36,10 +36,10 @@ class ModListSection extends Component private function fetchLatestMods(): Collection { - return Mod::select(['id', 'user_id', 'name', 'slug', 'teaser', 'thumbnail', 'featured', 'created_at']) + return Mod::select(['id', 'name', 'slug', 'teaser', 'thumbnail', 'featured', 'created_at']) ->withLatestSptVersion() ->withTotalDownloads() - ->with('user:id,name') + ->with('users:id,name') ->latest() ->limit(6) ->get(); @@ -47,15 +47,22 @@ class ModListSection extends Component private function fetchUpdatedMods(): Collection { - return Mod::select(['id', 'user_id', 'name', 'slug', 'teaser', 'thumbnail', 'featured']) + return Mod::select(['id', 'name', 'slug', 'teaser', 'thumbnail', 'featured']) ->withLastUpdatedVersion() ->withTotalDownloads() - ->with('user:id,name') + ->with('users:id,name') ->latest() ->limit(6) ->get(); } + public function render(): View + { + return view('components.mod-list-section', [ + 'sections' => $this->getSections(), + ]); + } + public function getSections(): array { return [ @@ -76,11 +83,4 @@ class ModListSection extends Component ], ]; } - - public function render(): View - { - return view('components.mod-list-section', [ - 'sections' => $this->getSections(), - ]); - } } diff --git a/database/factories/ModFactory.php b/database/factories/ModFactory.php index 0b8ca64..aef197b 100644 --- a/database/factories/ModFactory.php +++ b/database/factories/ModFactory.php @@ -4,7 +4,6 @@ namespace Database\Factories; use App\Models\License; use App\Models\Mod; -use App\Models\User; use Illuminate\Database\Eloquent\Factories\Factory; use Illuminate\Support\Str; use Random\RandomException; @@ -18,10 +17,10 @@ class ModFactory extends Factory */ public function definition(): array { + $name = fake()->catchPhrase(); return [ - 'user_id' => User::factory(), 'name' => $name, 'slug' => Str::slug($name), 'teaser' => fake()->sentence(), diff --git a/database/migrations/2024_05_15_022710_create_mods_table.php b/database/migrations/2024_05_15_022710_create_mods_table.php index e4b0477..cbe04b6 100644 --- a/database/migrations/2024_05_15_022710_create_mods_table.php +++ b/database/migrations/2024_05_15_022710_create_mods_table.php @@ -1,7 +1,6 @@ nullable() ->default(null) ->unique(); - $table->foreignIdFor(User::class) - ->constrained('users') - ->cascadeOnDelete() - ->cascadeOnUpdate(); $table->string('name'); $table->string('slug'); $table->string('teaser'); diff --git a/database/migrations/2024_05_15_023706_create_mod_users_table.php b/database/migrations/2024_05_15_023706_create_mod_users_table.php new file mode 100644 index 0000000..ad10a91 --- /dev/null +++ b/database/migrations/2024_05_15_023706_create_mod_users_table.php @@ -0,0 +1,29 @@ +id(); + $table->foreignId('mod_id')->constrained()->cascadeOnUpdate()->cascadeOnDelete(); + $table->foreignId('user_id')->constrained()->cascadeOnUpdate()->cascadeOnDelete(); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('mod_user'); + } +}; diff --git a/database/seeders/DatabaseSeeder.php b/database/seeders/DatabaseSeeder.php index 68b0148..264a204 100644 --- a/database/seeders/DatabaseSeeder.php +++ b/database/seeders/DatabaseSeeder.php @@ -38,7 +38,12 @@ class DatabaseSeeder extends Seeder $users = User::factory(100)->create(); // Add 200 mods, assigning them to the users we just created. - $mods = Mod::factory(200)->recycle([$users, $licenses])->create(); + $allUsers = $users->merge([$administrator, $moderator]); + $mods = Mod::factory(200)->recycle([$licenses])->create(); + foreach ($mods as $mod) { + $userIds = $allUsers->random(rand(1, 3))->pluck('id')->toArray(); + $mod->users()->attach($userIds); + } // Add 1000 mod versions, assigning them to the mods we just created. ModVersion::factory(1000)->recycle([$mods, $spt_versions])->create(); diff --git a/resources/views/components/mod-list.blade.php b/resources/views/components/mod-list.blade.php index 6e3c13e..f8ba548 100644 --- a/resources/views/components/mod-list.blade.php +++ b/resources/views/components/mod-list.blade.php @@ -24,7 +24,7 @@ {{ $mod->{$versionScope}->sptVersion->version }} -

By {{ $mod->user->name }}

+

By {{ $mod->users->pluck('name')->implode(', ') }}

{{ $mod->teaser }}

diff --git a/resources/views/mod/show.blade.php b/resources/views/mod/show.blade.php index 06c4eb2..3d8012a 100644 --- a/resources/views/mod/show.blade.php +++ b/resources/views/mod/show.blade.php @@ -25,7 +25,7 @@ {{ $mod->latestSptVersion->version }} -

{{ __('Created by') }} {{ $mod->user->name }}

+

{{ __('Created by') }} {{ $mod->users->pluck('name')->implode(', ') }}

{{ $mod->latestSptVersion->sptVersion->version }} {{ __('Compatible') }}

{{ $mod->total_downloads }} {{ __('Downloads') }}

From a927f109416304b87176241f1707ca3ec52a621d Mon Sep 17 00:00:00 2001 From: Refringe Date: Fri, 5 Jul 2024 14:35:00 -0400 Subject: [PATCH 02/20] Import Multiple Mod Authors The import script has been updated to pull in additional mod authors from the hub. --- .gitignore | 3 +- app/Jobs/ImportHubData.php | 52 +++++++++++++++++-- ...24_05_15_023706_create_mod_users_table.php | 2 + 3 files changed, 50 insertions(+), 7 deletions(-) diff --git a/.gitignore b/.gitignore index 5118f9d..6062808 100644 --- a/.gitignore +++ b/.gitignore @@ -7,8 +7,7 @@ /.idea /.phpunit.cache /.vscode -/caddy -/data/caddy +/data /node_modules /public/build /public/hot diff --git a/app/Jobs/ImportHubData.php b/app/Jobs/ImportHubData.php index 40c27d3..7136567 100644 --- a/app/Jobs/ImportHubData.php +++ b/app/Jobs/ImportHubData.php @@ -17,6 +17,7 @@ use Illuminate\Contracts\Queue\ShouldQueue; use Illuminate\Foundation\Bus\Dispatchable; use Illuminate\Queue\InteractsWithQueue; use Illuminate\Queue\SerializesModels; +use Illuminate\Support\Arr; use Illuminate\Support\Collection; use Illuminate\Support\Facades\Artisan; use Illuminate\Support\Facades\DB; @@ -35,6 +36,7 @@ class ImportHubData implements ShouldBeUnique, ShouldQueue { // Stream some data locally so that we don't have to keep accessing the Hub's database. Use MySQL temporary // tables to store the data to save on memory; we don't want this to be a hog. + $this->bringFileAuthorsLocal(); $this->bringFileOptionsLocal(); $this->bringFileContentLocal(); $this->bringFileVersionLabelsLocal(); @@ -56,6 +58,30 @@ class ImportHubData implements ShouldBeUnique, ShouldQueue Artisan::call('scout:import', ['model' => '\App\Models\Mod']); } + /** + * Bring the file authors from the Hub database to the local database temporary table. + */ + protected function bringFileAuthorsLocal(): void + { + DB::statement('DROP TEMPORARY TABLE IF EXISTS temp_file_author'); + DB::statement('CREATE TEMPORARY TABLE temp_file_author ( + fileID INT, + userID INT + )'); + + DB::connection('mysql_hub') + ->table('filebase1_file_author') + ->orderBy('fileID') + ->chunk(200, function ($relationships) { + foreach ($relationships as $relationship) { + DB::table('temp_file_author')->insert([ + 'fileID' => (int) $relationship->fileID, + 'userID' => (int) $relationship->userID, + ]); + } + }); + } + /** * Bring the file options from the Hub database to the local database temporary table. */ @@ -456,6 +482,14 @@ class ImportHubData implements ShouldBeUnique, ShouldQueue ->chunkById(100, function (Collection $mods) use ($curl) { foreach ($mods as $mod) { + // Fetch any additional authors for the mod. + $modAuthors = DB::table('temp_file_author') + ->where('fileID', $mod->fileID) + ->pluck('userID') + ->toArray(); + $modAuthors[] = $mod->userID; // Add the primary author to the list. + $modAuthors = User::whereIn('hub_id', $modAuthors)->pluck('id')->toArray(); // Replace with local IDs. + $modContent = DB::table('temp_file_content') ->where('fileID', $mod->fileID) ->orderBy('fileID', 'desc') @@ -494,9 +528,9 @@ class ImportHubData implements ShouldBeUnique, ShouldQueue continue; } - $insertData[] = [ + $modData[] = [ 'hub_id' => (int) $mod->fileID, - 'user_id' => User::whereHubId($mod->userID)->value('id'), + 'users' => $modAuthors, 'name' => $modContent?->subject ?? '', 'slug' => Str::slug($modContent?->subject ?? ''), 'teaser' => Str::limit($modContent?->teaser ?? ''), @@ -513,9 +547,11 @@ class ImportHubData implements ShouldBeUnique, ShouldQueue ]; } - if (! empty($insertData)) { - Mod::upsert($insertData, ['hub_id'], [ - 'user_id', + if (! empty($modData)) { + // Remove the user_id from the mod data before upserting. + $insertModData = array_map(fn ($mod) => Arr::except($mod, 'users'), $modData); + + Mod::upsert($insertModData, ['hub_id'], [ 'name', 'slug', 'teaser', @@ -525,10 +561,15 @@ class ImportHubData implements ShouldBeUnique, ShouldQueue 'source_code_link', 'featured', 'contains_ai_content', + 'contains_ads', 'disabled', 'created_at', 'updated_at', ]); + + foreach ($modData as $mod) { + Mod::whereHubId($mod['hub_id'])->first()?->users()->sync($mod['users']); + } } }, 'fileID'); @@ -666,6 +707,7 @@ class ImportHubData implements ShouldBeUnique, ShouldQueue public function failed(Exception $exception): void { // Explicitly drop the temporary tables. + DB::unprepared('DROP TEMPORARY TABLE IF EXISTS temp_file_author'); DB::unprepared('DROP TEMPORARY TABLE IF EXISTS temp_file_option_values'); DB::unprepared('DROP TEMPORARY TABLE IF EXISTS temp_file_content'); DB::unprepared('DROP TEMPORARY TABLE IF EXISTS temp_file_version_labels'); diff --git a/database/migrations/2024_05_15_023706_create_mod_users_table.php b/database/migrations/2024_05_15_023706_create_mod_users_table.php index ad10a91..c2ffb39 100644 --- a/database/migrations/2024_05_15_023706_create_mod_users_table.php +++ b/database/migrations/2024_05_15_023706_create_mod_users_table.php @@ -16,6 +16,8 @@ return new class extends Migration $table->foreignId('mod_id')->constrained()->cascadeOnUpdate()->cascadeOnDelete(); $table->foreignId('user_id')->constrained()->cascadeOnUpdate()->cascadeOnDelete(); $table->timestamps(); + + $table->unique(['mod_id', 'user_id']); }); } From ded4a3bf8428a9c8212cd1ba873978855827b7d1 Mon Sep 17 00:00:00 2001 From: Refringe Date: Fri, 5 Jul 2024 14:37:20 -0400 Subject: [PATCH 03/20] Administration Navigation Links Adds links to Horizon, Pulse, and Filament to the authenticated dropdown menu. --- resources/views/navigation-menu.blade.php | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/resources/views/navigation-menu.blade.php b/resources/views/navigation-menu.blade.php index eb856ba..fa16edf 100644 --- a/resources/views/navigation-menu.blade.php +++ b/resources/views/navigation-menu.blade.php @@ -80,6 +80,29 @@ @endif + @if (auth()->user()->isAdmin()) + + @endif
@csrf From a36c38db43f7c0241d6846bfbc0fbce1b56a63e0 Mon Sep 17 00:00:00 2001 From: Refringe Date: Fri, 5 Jul 2024 16:19:48 -0400 Subject: [PATCH 04/20] Updates warning banner message. --- resources/views/components/warning.blade.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/resources/views/components/warning.blade.php b/resources/views/components/warning.blade.php index 7a14867..a4c5ab0 100644 --- a/resources/views/components/warning.blade.php +++ b/resources/views/components/warning.blade.php @@ -1,4 +1,3 @@
-

Notice: The Forge is currently under - heavy construction. Expect nothing to work.

+

Notice: The Forge is currently under heavy construction. Expect nothing to work. Data is reset every hour.

From 33ad76849ebc3843fa47e14eff509882a57b5dab Mon Sep 17 00:00:00 2001 From: Refringe Date: Fri, 5 Jul 2024 17:52:23 -0400 Subject: [PATCH 05/20] Redis Sessions Back to Redis sessions. Speed, baby, YEAH! --- .env.full | 5 +++-- config/session.php | 2 +- .../0001_01_01_000000_create_users_table.php | 10 ---------- resources/views/profile/show.blade.php | 12 +++++++----- 4 files changed, 11 insertions(+), 18 deletions(-) diff --git a/.env.full b/.env.full index c5317c1..ae683d7 100644 --- a/.env.full +++ b/.env.full @@ -43,8 +43,8 @@ DB_HUB_PASSWORD= DB_HUB_CHARSET=utf8mb4 DB_HUB_COLLATION=utf8mb4_0900_ai_ci -SESSION_DRIVER=database -SESSION_CONNECTION=mysql +SESSION_DRIVER=redis +SESSION_CONNECTION=default SESSION_LIFETIME=120 SESSION_ENCRYPT=false SESSION_PATH=/ @@ -64,6 +64,7 @@ REDIS_HOST=redis REDIS_PASSWORD=null REDIS_PORT=6379 REDIS_QUEUE=default +REDIS_QUEUE_CONNECTION=queue REDIS_CACHE_CONNECTION=cache SCOUT_QUEUE=true diff --git a/config/session.php b/config/session.php index f0b6541..b209e78 100644 --- a/config/session.php +++ b/config/session.php @@ -18,7 +18,7 @@ return [ | */ - 'driver' => env('SESSION_DRIVER', 'database'), + 'driver' => env('SESSION_DRIVER', 'redis'), /* |-------------------------------------------------------------------------- diff --git a/database/migrations/0001_01_01_000000_create_users_table.php b/database/migrations/0001_01_01_000000_create_users_table.php index a14b4ab..5a965db 100644 --- a/database/migrations/0001_01_01_000000_create_users_table.php +++ b/database/migrations/0001_01_01_000000_create_users_table.php @@ -38,15 +38,6 @@ return new class extends Migration $table->string('token'); $table->timestamp('created_at')->nullable(); }); - - Schema::create('sessions', function (Blueprint $table) { - $table->string('id')->primary(); - $table->foreignId('user_id')->nullable()->index(); - $table->string('ip_address', 45)->nullable(); - $table->text('user_agent')->nullable(); - $table->longText('payload'); - $table->integer('last_activity')->index(); - }); } /** @@ -56,6 +47,5 @@ return new class extends Migration { Schema::dropIfExists('users'); Schema::dropIfExists('password_reset_tokens'); - Schema::dropIfExists('sessions'); } }; diff --git a/resources/views/profile/show.blade.php b/resources/views/profile/show.blade.php index b3c3055..a089e25 100644 --- a/resources/views/profile/show.blade.php +++ b/resources/views/profile/show.blade.php @@ -29,13 +29,15 @@ @endif -
- @livewire('profile.logout-other-browser-sessions-form') -
+ @if (config('session.driver') === 'database') +
+ @livewire('profile.logout-other-browser-sessions-form') +
+ + + @endif @if (Laravel\Jetstream\Jetstream::hasAccountDeletionFeatures()) - -
@livewire('profile.delete-user-form')
From 53b67b23ddae833dee210ec43408a1e601d5779c Mon Sep 17 00:00:00 2001 From: Refringe Date: Sat, 6 Jul 2024 19:14:51 -0400 Subject: [PATCH 06/20] Queueable Account Notifications The email verification and password reset notifications are now handled on a queue. --- app/Models/User.php | 18 ++++++++++++++++++ app/Notifications/ResetPassword.php | 25 +++++++++++++++++++++++++ app/Notifications/VerifyEmail.php | 20 ++++++++++++++++++++ 3 files changed, 63 insertions(+) create mode 100644 app/Notifications/ResetPassword.php create mode 100644 app/Notifications/VerifyEmail.php diff --git a/app/Models/User.php b/app/Models/User.php index 248fd04..224e5b5 100644 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -2,6 +2,8 @@ namespace App\Models; +use App\Notifications\ResetPassword; +use App\Notifications\VerifyEmail; use Illuminate\Contracts\Auth\MustVerifyEmail; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Relations\BelongsTo; @@ -76,6 +78,22 @@ class User extends Authenticatable implements MustVerifyEmail return Str::lower($this->role?->name) === 'administrator'; } + /** + * Overwritten to instead use the queued version of the VerifyEmail notification. + */ + public function sendEmailVerificationNotification(): void + { + $this->notify(new VerifyEmail); + } + + /** + * Overwritten to instead use the queued version of the ResetPassword notification. + */ + public function sendPasswordResetNotification(#[\SensitiveParameter] $token): void + { + $this->notify(new ResetPassword($token)); + } + protected function casts(): array { return [ diff --git a/app/Notifications/ResetPassword.php b/app/Notifications/ResetPassword.php new file mode 100644 index 0000000..85c4838 --- /dev/null +++ b/app/Notifications/ResetPassword.php @@ -0,0 +1,25 @@ + Date: Sat, 6 Jul 2024 19:45:42 -0400 Subject: [PATCH 07/20] Email Confirmation Language Updated the language of the email confirmation page to be more clear in that the user must click the button to receive the verification email. --- resources/views/auth/verify-email.blade.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/resources/views/auth/verify-email.blade.php b/resources/views/auth/verify-email.blade.php index e4f9fdf..1be8a06 100644 --- a/resources/views/auth/verify-email.blade.php +++ b/resources/views/auth/verify-email.blade.php @@ -5,12 +5,12 @@
- {{ __('Before continuing, could you verify your email address by clicking on the link we just emailed to you? If you didn\'t receive the email, we will gladly send you another.') }} + {{ __('Before continuing, please verify your email address. Click the button below and check your email for a verification link.') }}
@if (session('status') == 'verification-link-sent')
- {{ __('A new verification link has been sent to the email address you provided in your profile settings.') }} + {{ __('A verification link has been sent to the email address you provided in your profile settings.') }}
@endif @@ -20,7 +20,7 @@
- {{ __('Resend Verification Email') }} + {{ __('Send Verification Email') }}
From 06031a9ea374484ef07535ea622e304998db2a31 Mon Sep 17 00:00:00 2001 From: "waffle.lord" Date: Mon, 15 Jul 2024 16:14:12 -0400 Subject: [PATCH 08/20] fix blur shapes indexes to be above the home view video player --- resources/views/home.blade.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/resources/views/home.blade.php b/resources/views/home.blade.php index f590768..9e966fd 100644 --- a/resources/views/home.blade.php +++ b/resources/views/home.blade.php @@ -6,10 +6,10 @@ -