Skip to content

Paths override with dot in route name does not work #500

Closed
@sebj54

Description

@sebj54

Fortify Version

1.18.0

Laravel Version

10.16.2

PHP Version

8.2.8

Database Driver & Version

No response

Description

When there is a dot in the route name, it is not possible to customize route paths the way it is described in the default config:

'paths' => [
'login' => null,
'logout' => null,
'password.request' => null,
'password.reset' => null,
'password.email' => null,
'password.update' => null,
'register' => null,
'verification.notice' => null,
'verification.verify' => null,
'verification.send' => null,
'user-profile-information.update' => null,
'user-password.update' => null,
'password.confirm' => null,
'password.confirmation' => null,
'two-factor.login' => null,
'two-factor.enable' => null,
'two-factor.confirm' => null,
'two-factor.disable' => null,
'two-factor.qr-code' => null,
'two-factor.secret-key' => null,
'two-factor.recovery-codes' => null,
],

RoutePath will get the config value for a given path with the config() function (see below). Because of that, dots are representing config paths and each item before a dot is an array.

return config('fortify.paths.'.$routeName) ?? $default;

Instead, route paths should be declared with arrays actually:

return [
    'paths' => [
        'login' => null,
        'logout' => null,
        'password' => [
            'request' => null,
            'reset' => null,
            'email' => null,
            'update' => null,
            'confirm' => null,
            'confirmation' => null,
        ],
        'register' => null,
        'verification' => [
            'notice' => null,
            'verify' => null,
            'send' => null,
        ],
        'user-profile-information' => [
            'update' => null,
        ],
        'user-password' => [
            'update' => null,
        ],
        'two-factor' => [
            'login' => null,
            'enable' => null,
            'confirm' => null,
            'disable' => null,
            'qr-code' => null,
            'secret-key' => null,
            'recovery-codes' => null,
        ]
    ],
];

The easiest fix is to change the default config object (and maybe the docs). But I think it would be more relevant if RoutePath::for() would get the whole paths array with config('fortify.paths') and then get the custom path if it exists.

Steps To Reproduce

Define a custom path for a route with a dot (for instance two-factor.login):

// config.fortify.php
return [
    'paths' => [
        'two-factor.login' => '/custom/path',
    ],
];

Then get route list with php artisan route:list

👉 The custom path is not taken in account

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions