Re: [Catalyst] check_user_roles [ $user ], @roles ?
in my Catalyst app I use $c-check_user_roles(qw/Admin/) to determine, if the currently logged in user is part of the Admin role. Works fine. Now I want to check if _another_ (currently _not_ logged in user) is part of the Admin role. I read the documentation of Catalyst::Plugin::Authorization::Roles and found that check_user_roles can optionally take $user as additional parameter. But it does not work as I suspected: With ... $c-log-info( . $c-check_user_roles( some_other_user , qw/Admin/ )); ... Catalyst debug just gives me ... [debug] Role denied: some_other_user, Admin [info] ... where I expected something like ... [info] 1 some_other_user is a username string, in the column username of my user table. myapp/myapp.conf ist setup accordingly (i.e.: user_class myapp::user and id_field username). What am I doing wrong? $c-check_user_roles expects a user object not a username string (how would it distinguish a user name from a role name?). You can get a user object via $c-find_user. You mean something like ... my $foo = $c-find_user({ username = some_other_user }, my_realm); $c-log-info( . $c-check_user_roles($foo, qw/Admin/)); ? This gives me nearly the same output as before - i.e.: [debug] Role denied: Catalyst::Authentication::Store::DBIx::Class::User=HASH(0x9abd318), Admin [info] I guess I am misundestanding something. Any hints? -- Jetzt 1 Monat kostenlos! GMX FreeDSL - Telefonanschluss + DSL für nur 17,95 Euro/mtl.!* http://dsl.gmx.de/?ac=OM.AD.PD003K11308T4569a ___ 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] check_user_roles [ $user ], @roles ?
On Wed, Feb 4, 2009 at 10:03 AM, Jens Schwarz blacky6...@gmx.de wrote: Hi *, in my Catalyst app I use $c-check_user_roles(qw/Admin/) to determine, if the currently logged in user is part of the Admin role. Works fine. Now I want to check if _another_ (currently _not_ logged in user) is part of the Admin role. I read the documentation of Catalyst::Plugin::Authorization::Roles and found that check_user_roles can optionally take $user as additional parameter. But it does not work as I suspected: With ... $c-log-info( . $c-check_user_roles( some_other_user , qw/Admin/ )); ... Catalyst debug just gives me ... [debug] Role denied: some_other_user, Admin [info] ... where I expected something like ... [info] 1 some_other_user is a username string, in the column username of my user table. myapp/myapp.conf ist setup accordingly (i.e.: user_class myapp::user and id_field username). What am I doing wrong? $c-check_user_roles expects a user object not a username string (how would it distinguish a user name from a role name?). You can get a user object via $c-find_user. -- Eden Cardim Need help with your Catalyst or DBIx::Class project? Code Monkeyhttp://www.shadowcat.co.uk/catalyst/ Shadowcat Systems Ltd. Want a managed development or deployment platform? http://edenc.vox.com/http://www.shadowcat.co.uk/servers/ ___ 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] check_user_roles [ $user ], @roles ?
From the code: if ( Scalar::Util::blessed( $roles[0] ) $roles[0]-isa(Catalyst::Authentication::User) ) { $user = shift @roles; } $user ||= $c-user; unless ( $user ) { Catalyst::Exception-throw( No logged in user, and none supplied as argument); } Catalyst::Exception-throw(User does not support roles) unless $user-supports(qw/roles/); i think you can give a string ... you must load the user into a user-object fit for the Authorization::Roles Jens Schwarz schrieb: Hi *, in my Catalyst app I use $c-check_user_roles(qw/Admin/) to determine, if the currently logged in user is part of the Admin role. Works fine. Now I want to check if _another_ (currently _not_ logged in user) is part of the Admin role. I read the documentation of Catalyst::Plugin::Authorization::Roles and found that check_user_roles can optionally take $user as additional parameter. But it does not work as I suspected: With ... $c-log-info( . $c-check_user_roles( some_other_user , qw/Admin/ )); ... Catalyst debug just gives me ... [debug] Role denied: some_other_user, Admin [info] ... where I expected something like ... [info] 1 some_other_user is a username string, in the column username of my user table. myapp/myapp.conf ist setup accordingly (i.e.: user_class myapp::user and id_field username). What am I doing wrong? Jens -- Mit freundlichen Grüßen Felix Antonius Wilhelm Ostmann -- Websuche Search Technology GmbH Co. KG Martinistraße 3 - D-49080 Osnabrück - Germany Tel.: +49 541 40666-0 - Fax:+49 541 40666-22 Email: i...@websuche.de - Website: www.websuche.de -- AG Osnabrück - HRA 200252 - Ust-Ident: DE814737310 Komplementärin: Websuche Search Technology Verwaltungs GmbH - AG Osnabrück - HRB 200359 Geschäftsführer: Diplom Kaufmann Martin Steinkamp -- ___ 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] check_user_roles [ $user ], @roles ?
Hi *, in my Catalyst app I use $c-check_user_roles(qw/Admin/) to determine, if the currently logged in user is part of the Admin role. Works fine. Now I want to check if _another_ (currently _not_ logged in user) is part of the Admin role. I read the documentation of Catalyst::Plugin::Authorization::Roles and found that check_user_roles can optionally take $user as additional parameter. But it does not work as I suspected: With ... $c-log-info( . $c-check_user_roles( some_other_user , qw/Admin/ )); ... Catalyst debug just gives me ... [debug] Role denied: some_other_user, Admin [info] ... where I expected something like ... [info] 1 some_other_user is a username string, in the column username of my user table. myapp/myapp.conf ist setup accordingly (i.e.: user_class myapp::user and id_field username). What am I doing wrong? Jens -- Jetzt 1 Monat kostenlos! GMX FreeDSL - Telefonanschluss + DSL für nur 17,95 Euro/mtl.!* http://dsl.gmx.de/?ac=OM.AD.PD003K11308T4569a ___ 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] check_user_roles [ $user ], @roles ?
On Wed, Feb 4, 2009 at 10:50 AM, Felix Antonius Wilhelm Ostmann ostm...@websuche.de wrote: From the code: if ( Scalar::Util::blessed( $roles[0] ) $roles[0]-isa(Catalyst::Authentication::User) ) { $user = shift @roles; } $user ||= $c-user; That particular bit means you need to feed it a blessed scalar, namely, *an object*. i think you can give a string ... you must load the user into a user-object fit for the Authorization::Roles Not if you want it to DTRT. -- Eden Cardim Need help with your Catalyst or DBIx::Class project? Code Monkeyhttp://www.shadowcat.co.uk/catalyst/ Shadowcat Systems Ltd. Want a managed development or deployment platform? http://edenc.vox.com/http://www.shadowcat.co.uk/servers/ ___ 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] check_user_roles [ $user ], @roles ?
Eden Cardim schrieb: On Wed, Feb 4, 2009 at 10:50 AM, Felix Antonius Wilhelm Ostmann ostm...@websuche.de wrote: From the code: if ( Scalar::Util::blessed( $roles[0] ) $roles[0]-isa(Catalyst::Authentication::User) ) { $user = shift @roles; } $user ||= $c-user; That particular bit means you need to feed it a blessed scalar, namely, *an object*. i think you can give a string ... you must load the user into a user-object fit for the Authorization::Roles uh, that should be a can't give a string :( damn! Not if you want it to DTRT. -- Mit freundlichen Grüßen Felix Antonius Wilhelm Ostmann -- Websuche Search Technology GmbH Co. KG Martinistraße 3 - D-49080 Osnabrück - Germany Tel.: +49 541 40666-0 - Fax:+49 541 40666-22 Email: i...@websuche.de - Website: www.websuche.de -- AG Osnabrück - HRA 200252 - Ust-Ident: DE814737310 Komplementärin: Websuche Search Technology Verwaltungs GmbH - AG Osnabrück - HRB 200359 Geschäftsführer: Diplom Kaufmann Martin Steinkamp -- ___ 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/