Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Auth.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ public function routes(RouteCollection &$routes, array $config = [])

$routes->group('/', ['namespace' => 'CodeIgniter\Shield\Controllers'], static function ($routes) use ($authRoutes, $config) {
foreach ($authRoutes as $name => $row) {
if (! isset($config['except']) || (isset($config['except']) && ! array_key_exists($name, $config['except']))) {
if (! isset($config['except']) || (isset($config['except']) && ! in_array($name, $config['except'], true))) {
foreach ($row as $params) {
$options = isset($params[3])
? ['as' => $params[3]]
Expand Down
43 changes: 43 additions & 0 deletions tests/Unit/AuthRoutesTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?php

namespace Tests\Unit;

use Tests\Support\TestCase;

/**
* @internal
*/
final class AuthRoutesTest extends TestCase
{
public function testRoutes()
{
$collection = single_service('routes');
$auth = service('auth');

$auth->routes($collection);

$routes = $collection->getRoutes('get');

$this->assertArrayHasKey('register', $routes);
$this->assertArrayHasKey('login', $routes);
$this->assertArrayHasKey('login/magic-link', $routes);
$this->assertArrayHasKey('logout', $routes);
$this->assertArrayHasKey('auth/a/show', $routes);
}

public function testRoutesExcept()
{
$collection = single_service('routes');
$auth = service('auth');

$auth->routes($collection, ['except' => ['login']]);

$routes = $collection->getRoutes('get');

$this->assertArrayNotHasKey('login', $routes);
$this->assertArrayHasKey('register', $routes);
$this->assertArrayHasKey('login/magic-link', $routes);
$this->assertArrayHasKey('logout', $routes);
$this->assertArrayHasKey('auth/a/show', $routes);
}
}