-
Notifications
You must be signed in to change notification settings - Fork 133
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix: Unnamed Auth routes returns an error when inside a route group #577
Fix: Unnamed Auth routes returns an error when inside a route group #577
Conversation
I think this should be fine. @codeigniter4/core-team can you think of any reason this might be problematic? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me! Those should've been named routes to begin with.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks fine.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi, thanks for PR.
If you use the following code.
$routes->group('accounts', static function($routes) {
service('auth')->routes($routes);
});
The logout
path is not recognized because it is set to login
by default.
Line 51 in 3fede09
'logout' => 'login', |
So I expect you to consider this or at least add some explanation in the documentation.
Not sure I understand clearly what you mean. What you pointed out is the logout redirect, which by default, redirects to the login page. This PR fixes issues that may arise when the auth route is placed inside a group. If we are also considering the login/register/logout redirects, then I think using Is this what you mean @datamweb ? |
Step1: add $routes->group('accounts', static function($routes) {
service('auth')->routes($routes);
}); to file Step2: login with http://localhost:8080/accounts/login. what will happen? 404 error(404 - File Not Found Now if you change the Line 51 in 3fede09
So my point is that it should be explained that the grouping affects the exit performance of the user should know how to fix this issue or use as. |
As @datamweb says, it seems 404 error will be reported. Lines 42 to 52 in 3fede09
But the issue is not related to this PR? |
Yes, exactly that.
Well, if you think this is not related to PR, go ahead. merge. |
Now I understand your concern @datamweb. Can we change the What do you think @kenjis @MGatner @lonnieezell ? |
We cannot change it easily. Because it is a URL (path), not a route name. The value will be passed to Lines 375 to 380 in 3fede09
|
Shield is now in beta releases. So we could introduce breaking changes. When we are using named routes in Shield, So it seems better to change the
We can do that if we change |
If a site has more than one login URL (e.g. But there is probably no such site, so this change will not a problem. |
That was interesting. I had not thought about this position.
However, I agree with this. |
a20ad6b
to
57b3295
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for being with us.
We all strive to make Shield better.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
Sorry, I meant please update the explanation. Because it will be not only URL, but also named route. Lines 41 to 46 in 83dd09a
|
Is this really necessary? I'm asking because no change was done to the |
This description also needs to be updated. |
Oh, I get the point now, thank you. |
In the default state, the route So it would be better to have an explanation that if the route name is set, it is the route name. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
Co-authored-by: Pooya Parsa Dadashi <pooya_parsa_dadashi@yahoo.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awaiting approval from lonnieezell.
@lonnieezell Can you review? |
Approved |
In situations when a developer decides to put the routes in a group like so:
Calls to
route_to('login')
androute_to('register')
will return an error because there isn't any named route for that.By explicitly setting named routes for each of the auth routes, the routing works well whether in groups or not.