Hi All,
     I am quite a beginner for Catalyst. When I used Chained Controller to
handle  some permission pages, I met a problem

First I use this piece of code to make sure that a user is logged in, if
not, the use will be forward to the login page, and I assume after login, it
will return back to the original page


 sub base : Chained('/') : PathPart('user') : CaptureArgs(0) {
    my ($self, $c) = @_;
    if (!$c->user_exists) {
        $c->flash->{'message'} = "You need to login to view this page";
        $c->forward('login');
      }
    $c->stash->{'resultset'} = $c->model('DB::User');
 }


So in the other actions, I don't need to check the user is logged in or not


  sub get : Chained('base') : PathPart("") : CaptureArgs('1') {
    my ($self, $c, $id) = @_;

    if ($c->user->id == $id) {
    ...........
  }


But it did not work out as I thought so, when I try to access  some page,
eg. /user/$id/view
I got a error

Caught exception in SEA::Controller::User->get "Can't call method "id"
on an undefined value


What is the problem with this code?


-- 
Woosley.Xu
_______________________________________________
List: [email protected]
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/[email protected]/
Dev site: http://dev.catalyst.perl.org/

Reply via email to