-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathModuleServiceProvider.php
More file actions
32 lines (27 loc) · 1.03 KB
/
ModuleServiceProvider.php
File metadata and controls
32 lines (27 loc) · 1.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
<?php
declare(strict_types=1);
namespace Modules\Auth;
use Modules\Auth\Middleware\RedirectIfAuthenticated;
use Modules\Auth\Middleware\RequireAuth;
use Modules\Auth\Support\PasswordResetBroker;
use Wayfinder\Database\Database;
use Wayfinder\Module\Module;
use Wayfinder\Module\ServiceProvider;
use Wayfinder\Routing\Router;
use Wayfinder\Support\Config;
use Wayfinder\Support\Container;
final class ModuleServiceProvider extends ServiceProvider
{
public function register(Container $container, Config $config, Module $module): void
{
$container->singleton(PasswordResetBroker::class, static fn (Container $c) => new PasswordResetBroker(
$c->get(Database::class),
(int) $config->get('auth.password_reset_ttl', 3600),
));
}
public function boot(Container $container, Router $router, Config $config, Module $module): void
{
$router->middlewareGroup('auth.web', ['web', RequireAuth::class, 'no-cache']);
$router->aliasMiddleware('guest', RedirectIfAuthenticated::class);
}
}