Files
fotospiel-app/app/Providers/AuthServiceProvider.php
Codex Agent 3de1d3deab
Some checks failed
linter / quality (push) Has been cancelled
tests / ci (push) Has been cancelled
tests / ui (push) Has been cancelled
Misc unrelated updates
2026-01-12 10:31:31 +01:00

53 lines
1.5 KiB
PHP

<?php
namespace App\Providers;
use App\Models\PurchaseHistory;
use App\Models\Tenant;
use App\Models\User;
use App\Policies\PurchaseHistoryPolicy;
use App\Policies\TenantPolicy;
use Illuminate\Auth\Notifications\VerifyEmail;
use Illuminate\Foundation\Support\Providers\AuthServiceProvider as ServiceProvider;
use Illuminate\Support\Facades\Gate;
use Illuminate\Support\Facades\URL;
class AuthServiceProvider extends ServiceProvider
{
/**
* The policy mappings for the application.
*
* @var array<class-string, class-string>
*/
protected $policies = [
Tenant::class => TenantPolicy::class,
PurchaseHistory::class => PurchaseHistoryPolicy::class,
];
/**
* Register any authentication / authorization services.
*/
public function boot(): void
{
$this->registerPolicies();
VerifyEmail::createUrlUsing(function (User $notifiable): string {
$relativeUrl = URL::temporarySignedRoute(
'verification.verify',
now()->addMinutes((int) config('auth.verification.expire', 60)),
[
'id' => $notifiable->getKey(),
'hash' => sha1($notifiable->getEmailForVerification()),
],
absolute: false,
);
return URL::to($relativeUrl);
});
Gate::before(function (User $user): ?bool {
return $user->isSuperAdmin() ? true : null;
});
}
}