[Catalyst] Transferring control via root/auto

David Schmidt davewood at gmx.at
Tue Dec 7 16:19:54 GMT 2010


On Tue, Dec 7, 2010 at 4:53 PM, Thompson <robt at matsch.com> wrote:
> Here is my problem,
>
> If a user logs in for the 1st time I want to force them to change their
> password.  I have a specific action in my Users controller to handle
> that.  What I'm having a problem with is (redirecting or forwarding or
> detaching - i've tried them all) from the root/auto function to my
> specific controller function.  I either get an internal server error or
> page isn't redirecting properly, depending what i use.  I've put my
> logic in the root/auto because regardless of the request changing their
> password is mandatory.
>
> Here is my current root/auto using redirect.
>
> sub auto : Private {
>          my ($self, $c) = @_;
>
>          if ($c->user_exists()&&  $c->check_any_user_role('User')
> &&  $c->user->changePassword  ) {
>
> $c->res->redirect($c->uri_for($c->controller('Users')->action_for('loginedit'),
> [$c->user->id] ));
>                 $c->detach();
>          }
>
>          return 1;
>      }
>
> Any help would be appreciated.
> Rob T
>
> _______________________________________________
> List: Catalyst at 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/
>

I wouldn't put that into an auto method. I remember t0m saying that
you can use Chained Dispatchtype instead of auto most of the time.

Anyways, the error message of your devel server would sure help
finding the problem.

david



More information about the Catalyst mailing list