X-Git-Url: https://ruin.nu/git/?a=blobdiff_plain;f=lib%2FNDWeb%2FController%2FJSRPC.pm;h=3bea69a5405e5c14983503767410d1eaf2a28ea0;hb=fa041ffba328c26a58506d5ccabed93d29106473;hp=41c7c3d6ebf4df47ce0dd08edb2159e367b99959;hpb=b1a7289bb7acbb4e911b62557acb7812492d90d5;p=ndwebbie.git diff --git a/lib/NDWeb/Controller/JSRPC.pm b/lib/NDWeb/Controller/JSRPC.pm index 41c7c3d..3bea69a 100644 --- a/lib/NDWeb/Controller/JSRPC.pm +++ b/lib/NDWeb/Controller/JSRPC.pm @@ -4,6 +4,8 @@ use strict; use warnings; use parent 'Catalyst::Controller'; +use DateTime::TimeZone; + =head1 NAME NDWeb::Controller::JSRPC - Catalyst Controller @@ -187,6 +189,19 @@ sub listTargets : Local { $c->forward('/listTargets'); } +sub tzcountries : Local { + my ($self, $c, $cat) = @_; + + my @countries = DateTime::TimeZone->names_in_category($cat); + $c->stash(tzcountries => \@countries); +} + +sub access_denied : Private { + my ($self, $c) = @_; + $c->stash(template => 'jsrpc/access_denied.tt2'); + $c->res->status(403); +} + sub assertTarget : Private { my ($self, $c, $raid, $from, $target, $wave) = @_; my $dbh = $c->model; @@ -207,6 +222,18 @@ sub assertTarget : Private { sub end : ActionClass('RenderView') { my ($self,$c) = @_; $c->res->content_type('application/xml'); + + if (scalar @{ $c->error } ){ + if ($c->error->[0] =~ m/Can't call method "id" on an undefined value at/){ + $c->stash->{template} = 'jsrpc/access_denied.tt2'; + $c->res->status(403); + $c->clear_errors; + }elsif ($c->error->[0] =~ m/Missing roles: /){ + $c->stash->{template} = 'jsrpc/access_denied.tt2'; + $c->res->status(403); + $c->clear_errors; + } + } } =head1 AUTHOR