This repository has been archived by the owner on Apr 2, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: using auth() helper instead of read through database in the…
… middleware
- Loading branch information
Showing
2 changed files
with
58 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
<?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. | ||
* | ||
* @return void | ||
*/ | ||
public function register() | ||
{ | ||
// | ||
} | ||
|
||
/** | ||
* Bootstrap any application services. | ||
* | ||
* @return void | ||
*/ | ||
public function boot() | ||
{ | ||
Fortify::createUsersUsing(CreateNewUser::class); | ||
Fortify::updateUserProfileInformationUsing(UpdateUserProfileInformation::class); | ||
Fortify::updateUserPasswordsUsing(UpdateUserPassword::class); | ||
Fortify::resetUserPasswordsUsing(ResetUserPassword::class); | ||
|
||
Fortify::loginView(fn () => view('auth.login')); | ||
Fortify::registerView(fn () => view('auth.register')); | ||
Fortify::requestPasswordResetLinkView(fn () => view('auth.passwords.email')); | ||
Fortify::resetPasswordView(fn () => view('auth.passwords.reset')); | ||
|
||
RateLimiter::for('login', function (Request $request) { | ||
return Limit::perMinute(5)->by($request->email.$request->ip()); | ||
}); | ||
|
||
RateLimiter::for('two-factor', function (Request $request) { | ||
return Limit::perMinute(5)->by($request->session()->get('login.id')); | ||
}); | ||
|
||
$this->app->singleton( | ||
\Laravel\Fortify\Contracts\LoginResponse::class, | ||
\App\Http\Responses\LoginResponse::class | ||
); | ||
} | ||
} |