Wires AuthController (signup, confirmEmail, login, me, logout) to the existing auth use cases. Routes mounted under /api with AuthMiddleware on logout/me. RepositoryServiceProvider gains EmailConfirmationToken and Post bindings; AppServiceProvider binds the Emailer/EmailFactory and constructs SignupUser with the configured from-address.
59 lines
1.9 KiB
PHP
59 lines
1.9 KiB
PHP
<?php
|
|
|
|
namespace App\Providers;
|
|
|
|
use App\Auth\BcryptPasswordHasher;
|
|
use App\Auth\Clock;
|
|
use App\Auth\PasswordHasher;
|
|
use App\Auth\RandomTokenGenerator;
|
|
use App\Auth\SystemClock;
|
|
use App\Auth\TokenGenerator;
|
|
use App\Email\EmailConfirmationToken\EmailConfirmationTokenRepository;
|
|
use App\Email\Emailer;
|
|
use App\Email\EmailFactory;
|
|
use App\Email\LaravelEmailFactory;
|
|
use App\Email\LaravelMailer;
|
|
use App\User\UseCases\SignupUser\SignupUser;
|
|
use App\User\UserRepository;
|
|
use Illuminate\Contracts\Foundation\Application;
|
|
use Illuminate\Support\ServiceProvider;
|
|
|
|
class AppServiceProvider extends ServiceProvider
|
|
{
|
|
public function register(): void
|
|
{
|
|
$this->app->bind(Clock::class, SystemClock::class);
|
|
$this->app->bind(TokenGenerator::class, RandomTokenGenerator::class);
|
|
$this->app->bind(PasswordHasher::class, BcryptPasswordHasher::class);
|
|
$this->app->bind(Emailer::class, LaravelMailer::class);
|
|
$this->app->bind(
|
|
EmailFactory::class,
|
|
function () {
|
|
return new LaravelEmailFactory(
|
|
confirmationUrlPrefix: config('app.frontend_url')
|
|
.'/confirm-email?token=',
|
|
);
|
|
},
|
|
);
|
|
$this->app->bind(
|
|
SignupUser::class,
|
|
function (Application $app) {
|
|
return new SignupUser(
|
|
userRepo: $app->make(UserRepository::class),
|
|
tokenRepo: $app->make(
|
|
EmailConfirmationTokenRepository::class,
|
|
),
|
|
emailer: $app->make(Emailer::class),
|
|
emailFactory: $app->make(EmailFactory::class),
|
|
clock: $app->make(Clock::class),
|
|
fromAddress: config('mail.from.address'),
|
|
);
|
|
},
|
|
);
|
|
}
|
|
|
|
public function boot(): void
|
|
{
|
|
//
|
|
}
|
|
}
|