liberu-genealogy / genealogy-laravel

Full genealogy application using Laravel 11, PHP 8.3, Filament 3.2 and Livewire 3.5
https://www.liberu.co.uk
MIT License
104 stars 58 forks source link

Sweep: copy jetstream providers #657

Closed curtisdelicata closed 1 month ago

curtisdelicata commented 1 month ago

Details

Copy the files from https://github.com/laravel/jetstream/tree/5.x/stubs%2Fapp%2FProviders into app/Providers

sweep-ai[bot] commented 1 month ago

🚀 Here's the PR! #662

💎 Sweep Pro: You have unlimited Sweep issues

Actions

Relevant files (click to expand). Mentioned files will always appear here. https://github.com/liberu-genealogy/genealogy-laravel/blob/06cac25756501bc901326db7307ca6a38d6cfb51/app/Providers/TeamServiceProvider.php#L1-L44 https://github.com/liberu-genealogy/genealogy-laravel/blob/06cac25756501bc901326db7307ca6a38d6cfb51/config/app.php#L1-L259 https://github.com/liberu-genealogy/genealogy-laravel/blob/06cac25756501bc901326db7307ca6a38d6cfb51/app/Providers/RouteServiceProvider.php#L1-L47 https://github.com/liberu-genealogy/genealogy-laravel/blob/06cac25756501bc901326db7307ca6a38d6cfb51/app/Providers/AuthServiceProvider.php#L1-L27 https://github.com/liberu-genealogy/genealogy-laravel/blob/06cac25756501bc901326db7307ca6a38d6cfb51/app/Providers/EventServiceProvider.php#L1-L46

Step 2: ⌨️ Coding

app/Providers/JetstreamServiceProvider.php

Create a new file for the Jetstream service provider.
<?php

namespace App\Providers;

use App\Actions\Jetstream\DeleteUser;
use Illuminate\Support\ServiceProvider;
use Laravel\Jetstream\Jetstream;

class JetstreamServiceProvider extends ServiceProvider
{
    /**
     * Register any application services.
     */
    public function register(): void
    {
        //
    }

    /**
     * Bootstrap any application services.
     */
    public function boot(): void
    {
        $this->configurePermissions();

        Jetstream::deleteUsersUsing(DeleteUser::class);
    }

    /**
     * Configure the permissions that are available within the application.
     */
    protected function configurePermissions(): void
    {
        Jetstream::defaultApiTokenPermissions(['read']);

        Jetstream::permissions([
            'create',
            'read',
            'update',
            'delete',
        ]);
    }
}

app/Providers/FortifyServiceProvider.php

Create a new file for the Fortify service provider.
<?php

namespace App\Providers;

use App\Actions\Fortify\CreateNewUser;
use App\Actions\Fortify\ResetUserPassword;
use App\Actions\Fortify\UpdateUserPassword;
use App\Actions\Fortify\UpdateUserProfileInformation;
use Illuminate\Cache\RateLimiting\Limit;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\RateLimiter;
use Illuminate\Support\ServiceProvider;
use Laravel\Fortify\Fortify;

class FortifyServiceProvider extends ServiceProvider
{
    /**
     * Register any application services.
     */
    public function register(): void
    {
        //
    }

    /**
     * Bootstrap any application services.
     */
    public function boot(): void
    {
        Fortify::createUsersUsing(CreateNewUser::class);
        Fortify::updateUserProfileInformationUsing(UpdateUserProfileInformation::class);
        Fortify::updateUserPasswordsUsing(UpdateUserPassword::class);
        Fortify::resetUserPasswordsUsing(ResetUserPassword::class);

        RateLimiter::for('login', function (Request $request) {
            $email = (string) $request->email;

            return Limit::perMinute(5)->by($email.$request->ip());
        });

        RateLimiter::for('two-factor', function (Request $request) {
            return Limit::perMinute(5)->by($request->session()->get('login.id'));
        });
    }
}

app/Providers/FortifyServiceProvider.php

Create a new file for the Fortify service provider.
<?php

namespace App\Providers;

use App\Actions\Fortify\CreateNewUser;
use App\Actions\Fortify\ResetUserPassword;
use App\Actions\Fortify\UpdateUserPassword;
use App\Actions\Fortify\UpdateUserProfileInformation;
use Illuminate\Cache\RateLimiting\Limit;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\RateLimiter;
use Illuminate\Support\ServiceProvider;
use Laravel\Fortify\Fortify;

class FortifyServiceProvider extends ServiceProvider
{
    /**
     * Register any application services.
     */
    public function register(): void
    {
        //
    }

    /**
     * Bootstrap any application services.
     */
    public function boot(): void
    {
        Fortify::createUsersUsing(CreateNewUser::class);
        Fortify::updateUserProfileInformationUsing(UpdateUserProfileInformation::class);
        Fortify::updateUserPasswordsUsing(UpdateUserPassword::class);
        Fortify::resetUserPasswordsUsing(ResetUserPassword::class);

        RateLimiter::for('login', function (Request $request) {
            $email = (string) $request->email;

            return Limit::perMinute(5)->by($email.$request->ip());
        });

        RateLimiter::for('two-factor', function (Request $request) {
            return Limit::perMinute(5)->by($request->session()->get('login.id'));
        });
    }
}

config/app.php

Update the providers array to include the new service providers.
--- 
+++ 
@@ -40,6 +40,8 @@
         App\Providers\Filament\AdminPanelProvider::class,
         App\Providers\RouteServiceProvider::class,
         App\Providers\TeamServiceProvider::class,
+        App\Providers\JetstreamServiceProvider::class,
+        App\Providers\FortifyServiceProvider::class,

         /*
          * Livewire Service Provider

Step 3: 🔄️ Validating

Your changes have been successfully made to the branch sweep/copy_jetstream_providers. I have validated these changes using a syntax checker and a linter.


[!TIP] To recreate the pull request, edit the issue title or description.

This is an automated message generated by Sweep AI.