| 1 | package Rapi::Blog::Controller::Remote::PreauthAction; | ||
| 2 | use Moose; | ||
| 3 | use namespace::autoclean; | ||
| 4 | |||
| 5 | BEGIN { extends 'Catalyst::Controller'; } | ||
| 6 | |||
| 7 | __PACKAGE__->config( namespace => 'remote/preauth_action' ); | ||
| 8 | |||
| 9 | use strict; | ||
| 10 | use warnings; | ||
| 11 | |||
| 12 | use RapidApp::Util ':all'; | ||
| 13 | use Rapi::Blog::Util; | ||
| 14 | |||
| 15 | sub index :Path :Args(1) { | ||
| 16 | my ($self, $c, $key) = @_; | ||
| 17 | |||
| 18 | my $Actor = $c | ||
| 19 | ->model('DB::PreauthAction') | ||
| 20 | ->request_Actor($c,$key); | ||
| 21 | |||
| 22 | $Actor->call_execute; | ||
| 23 | |||
| 24 | if (my $url = $Actor->redirect_url) { | ||
| 25 | $url =~ s/^\///; | ||
| 26 | return $c->res->redirect( join('/', $c->mount_url, $url), 307 ); | ||
| 27 | } | ||
| 28 | |||
| 29 | my $tpl = $Actor->render_template or die "Error - Actor has neither redirect or render instructions, this is a bug"; | ||
| 30 | |||
| 31 | return $c->detach( '/rapidapp/template/view', [$tpl] ); | ||
| 32 | } | ||
| 33 | |||
| 34 | |||
| 35 | |||
| 36 | __PACKAGE__->meta->make_immutable; | ||
| 37 | |||
| 38 | 1; | ||
| 39 | |||
| 40 | __END__ |