Closed pavelsr closed 7 years ago
Hi Pavel,
$self->logout will recurse - you have a sub 'logout' defined, and the actual 'logout' from my module is just a helper, so it'll recurse :)
If you do this, it'll work:
sub do_logout { my $self = shift; $self->logout; $self->redirect_to('/login'); }
And then refer to it with 'do_logout' in your routes :)
On 06/01/2016 04:30 PM, Pavel Serikov wrote:
Hi all,
I have a strange problem.
When I press logout link at my project computer is hanging and I have following at morbo log:
|Deep recursion on subroutine "MongoPA::Controller::Auth::logout" |
This is my logout function of MongoPA::Controller::Auth module:
sub logout { my $self = shift; $self->logout; $self->redirect_to('/login'); }
And this is related string from a route and template:
$r->get('/logout')->to('auth#logout'); logout
Is it a bug or I made something wrong?
I checked the code https://metacpan.org/source/MADCAT/Mojolicious-Plugin-Authentication-1.29/lib/Mojolicious/Plugin/Authentication.pm#L117 of logout method and I haven't found anything that can make such deep recursion error. So I'm a little bit stuck now.
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/benvanstaveren/Mojolicious-Plugin-Authentication/issues/20, or mute the thread https://github.com/notifications/unsubscribe/AAQxlAIGb2bfKjHTb0KqJWzPnshYC09Nks5qHZeUgaJpZM4IrnAH.
Hi Ben,
Got it, thanks a lot. I just forgot that helpers and custom controller's methods have same namespace. You can close this issue.
P.S. However I think that we should figure out in documentation that to avoid recursion you shouldn't name your controller method as 'logout' :)
Yeah, that's a good point - I'm in the process of a rather significant rewrite, so I'll see if I can do something documentation/helper wise.
On 06/01/2016 04:49 PM, Pavel Serikov wrote:
Hi Ben,
Got it, thanks a lot. I just forgot that helpers and custom controller's methods have same namespace. Will close this issue.
P.S. However I think that we should figure out in documentation https://metacpan.org/pod/Mojolicious::Plugin::Authentication#logout that to avoid recursion you shouldn't name your controller method as 'logout' :)
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/benvanstaveren/Mojolicious-Plugin-Authentication/issues/20#issuecomment-223016842, or mute the thread https://github.com/notifications/unsubscribe/AAQxlFYfrii7MRi3MJCuWDl1mlCwcWSnks5qHZwCgaJpZM4IrnAH.
Hi all,
I have a strange problem.
When I press logout link at my project computer is hanging and I have following at morbo log:
This is my logout function of MongoPA::Controller::Auth module:
And this is related string from a route and template:
Is it a bug or I made something wrong?
I checked the code of logout method and I haven't found anything that can make such deep recursion error. So I'm a little bit stuck now.