Re: [Catalyst] How to get default()-like behavior outside of the Root controller
I'd rather split one application into several (admin app, survey app, etc) and join its via middleware. But you can try this: In MyApp::Admin: sub default : Path('admin') { # or # sub default : Chained(base) PathPart('') Path { my ( $self, $c ) = @_; $c-response-body( 'Page not found in /admin/...' ); $c-response-status(404); } In MyApp::Survey; sub default : Path('survey') { # or # sub default : Chained(base) PathPart('') Path { my ( $self, $c ) = @_; $c-response-body( 'Page not found in /survey/...' ); $c-response-status(404); } On 7 February 2015 at 01:51, Trevor Leffler tleff...@uw.edu wrote: Some of my top-level controllers represent different, er... major pieces of my application. They have, among other things, different default views, which are mainly just for configuring different page wrappers. These controllers have this action pattern: package MyApp::Admin; sub base : Chained('/') : PathPart('admin') : CaptureArgs(0) { ... } sub index : Chained('base') : PathPart('') : Args(0) { ... } package MyApp::Survey; sub base : Chained('/') : PathPart('survey') : CaptureArgs(0) { ... } ...etc... Requests for non-extant paths fall through to Root-default(), which gives the (undesired) default root view. I tried giving my top-level controllers their own default() methods, but as others have found [1], 'default() : Path' has precedence over 'index : Chained'. Otherwise, I get the appropriate view with 'Page Not Found' content for bad urls, e.g. /admin/blargh or /survey/123/nurgle I am looking for suggestions/solutions to get the desired behavior. Changing index() to 'index : Path' is not a viable option. Thanks, --Trevor [1] http://www.gossamer-threads.com/lists/catalyst/users/24883 ___ List: Catalyst@lists.scsys.co.uk Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/ Dev site: http://dev.catalyst.perl.org/ -- //wbr, Dmitry L. ___ List: Catalyst@lists.scsys.co.uk Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/ Dev site: http://dev.catalyst.perl.org/
Re: [Catalyst] How to get default()-like behavior outside of the Root controller
On 2/9/2015 1:59 AM, Dmitry L. wrote: I'd rather split one application into several (admin app, survey app, etc) and join its via middleware. But you can try this: In MyApp::Admin: sub default : Path('admin') { # or # sub default : Chained(base) PathPart('') Path { my ( $self, $c ) = @_; $c-response-body( 'Page not found in /admin/...' ); $c-response-status(404); } Neither of these work, as in both cases default() wins over index() except when index is defined as 'sub index : Path', which isn't a good option for me. And... I'd imagine that having both default and index defined with : Chained('base') PathPart('') Args(0) would lead to a collision and/or non-deterministic behavior...? --Trevor In MyApp::Survey; sub default : Path('survey') { # or # sub default : Chained(base) PathPart('') Path { my ( $self, $c ) = @_; $c-response-body( 'Page not found in /survey/...' ); $c-response-status(404); } On 7 February 2015 at 01:51, Trevor Leffler tleff...@uw.edu wrote: Some of my top-level controllers represent different, er... major pieces of my application. They have, among other things, different default views, which are mainly just for configuring different page wrappers. These controllers have this action pattern: package MyApp::Admin; sub base : Chained('/') : PathPart('admin') : CaptureArgs(0) { ... } sub index : Chained('base') : PathPart('') : Args(0) { ... } package MyApp::Survey; sub base : Chained('/') : PathPart('survey') : CaptureArgs(0) { ... } ...etc... Requests for non-extant paths fall through to Root-default(), which gives the (undesired) default root view. I tried giving my top-level controllers their own default() methods, but as others have found [1], 'default() : Path' has precedence over 'index : Chained'. Otherwise, I get the appropriate view with 'Page Not Found' content for bad urls, e.g. /admin/blargh or /survey/123/nurgle I am looking for suggestions/solutions to get the desired behavior. Changing index() to 'index : Path' is not a viable option. Thanks, --Trevor [1] http://www.gossamer-threads.com/lists/catalyst/users/24883 ___ List: Catalyst@lists.scsys.co.uk Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/ Dev site: http://dev.catalyst.perl.org/ -- Trevor Leffler, Sr. Software Engineer Office of Educational Assessment University of Washington 4311 11th Ave NE, Seattle, WA 98195 tel 206.616.1479 | fax 206.543.3961 http://www.washington.edu/oea ___ List: Catalyst@lists.scsys.co.uk Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/ Dev site: http://dev.catalyst.perl.org/
Re: [Catalyst] question about authorization and roles
Luca, Perhaps it's a stupid question, but have you checked that the user exists? if ( $c-user_exists() ... jb On Monday, February 9, 2015 7:53 AM, Luca Ferrari fluca1...@infinito.it wrote: Hi all, I'm trying to setup the authorization in an application, and therefore in my controller method I've something like the following: if ( ! $c-check_any_user_role( qw/Admin Manutentore/ ) ){ } and the above is always failing. At first I thought I was missing something with the role configuration, but in my application I also use ACLS that to the same path are configured as follows (and do work): if ( ! $c-check_any_user_role( qw/Admin Manutentore/ ) ) The configuration of the application is as follows: __PACKAGE__-config('Plugin:: Authentication' = { default_realm = 'members', realms = { members = { credential = { class = 'Password', password_field = 'password', password_type = 'clear' }, store = { class = 'DBIx::Class', user_model = 'SmicketsDB::User', role_relation = 'roles', role_field = 'description', } } } }); Any idea about? Thanks, Luca ___ List: Catalyst@lists.scsys.co.uk Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/ Dev site: http://dev.catalyst.perl.org/ ___ List: Catalyst@lists.scsys.co.uk Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/ Dev site: http://dev.catalyst.perl.org/
Re: [Catalyst] question about authorization and roles
Ciao, On Mon, Feb 9, 2015 at 6:12 PM, Jeff Black jeffrey.bl...@yahoo.com wrote: Perhaps it's a stupid question, but have you checked that the user exists? if ( $c-user_exists() ... Apparently it exists because I print the username and its role list to check...and of course the role is there. Luca ___ List: Catalyst@lists.scsys.co.uk Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/ Dev site: http://dev.catalyst.perl.org/
Re: [Catalyst] How to get default()-like behavior outside of the Root controller
On 9 February 2015 at 10:59, Dmitry L. dim0...@gmail.com wrote: I'd rather split one application into several (admin app, survey app, etc) and join its via middleware. I wrote a blog article a few months ago: http://blogs.perl.org/users/davewood/2014/08/splitting-a-catalyst-app-and-recombining-it-with-plackbuilder.html ___ List: Catalyst@lists.scsys.co.uk Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/ Dev site: http://dev.catalyst.perl.org/
[Catalyst] question about authorization and roles
Hi all, I'm trying to setup the authorization in an application, and therefore in my controller method I've something like the following: if ( ! $c-check_any_user_role( qw/Admin Manutentore/ ) ){ } and the above is always failing. At first I thought I was missing something with the role configuration, but in my application I also use ACLS that to the same path are configured as follows (and do work): if ( ! $c-check_any_user_role( qw/Admin Manutentore/ ) ) The configuration of the application is as follows: __PACKAGE__-config('Plugin:: Authentication' = { default_realm = 'members', realms = { members = { credential = { class = 'Password', password_field = 'password', password_type = 'clear' }, store = { class = 'DBIx::Class', user_model = 'SmicketsDB::User', role_relation = 'roles', role_field = 'description', } } } }); Any idea about? Thanks, Luca ___ List: Catalyst@lists.scsys.co.uk Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/ Dev site: http://dev.catalyst.perl.org/