]> ruin.nu Git - ndwebbie.git/blobdiff - lib/NDWeb/Controller/Root.pm
New fleet infrastructure
[ndwebbie.git] / lib / NDWeb / Controller / Root.pm
index 05f2ef8fe258801968c6099b47a8dec127d7ece1..6099db5805cda9a266914728cc52463f179e3ce1 100644 (file)
@@ -38,7 +38,8 @@ sub index : Local Path Args(0) {
 
 sub default : Path {
        my ( $self, $c ) = @_;
-       $c->response->status(404);
+       $c->stash(template => 'default.tt2');
+       $c->response->status(410);
 }
 
 sub login : Local {
@@ -146,13 +147,14 @@ sub auto : Private {
 
 sub redirect : Private {
        my ($self, $c) = @_;
-       $c->res->redirect($c->uri_for('/'.$c->flash->{referrer}));
+       $c->res->redirect($c->uri_for('/'.$c->session->{referrer}));
 }
 
 sub access_denied : Private {
        my ($self, $c, $action) = @_;
 
        $c->stash->{template} = 'access_denied.tt2';
+       $c->res->status(403);
 
 }
 
@@ -165,7 +167,7 @@ Attempt to render a view, if needed.
 sub end : ActionClass('RenderView') {
        my ($self, $c) = @_;
 
-       if ($c->res->status == 302){
+       if ($c->res->status >= 300 && $c->res->status <= 400 ){
                return;
        }
 
@@ -174,9 +176,11 @@ sub end : ActionClass('RenderView') {
        if (scalar @{ $c->error } ){
                if ($c->error->[0] =~ m/Can't call method "id" on an undefined value at/){
                        $c->stash->{template} = 'access_denied.tt2';
+                       $c->res->status(403);
                        $c->clear_errors;
                }elsif ($c->error->[0] =~ m/Missing roles: /){
                        $c->stash->{template} = 'access_denied.tt2';
+                       $c->res->status(403);
                        $c->clear_errors;
                }
        }
@@ -184,8 +188,9 @@ sub end : ActionClass('RenderView') {
        if ($c->user_exists){
                my $fleetupdate = 0;
                if ($c->check_user_roles(qw/member_menu/)){
-                       $fleetupdate = $dbh->selectrow_array(q{SELECT tick FROM fleets WHERE sender = ?
-                               AND mission = 'Full fleet' AND tick > tick() - 24
+                       $fleetupdate = $dbh->selectrow_array(q{
+SELECT tick FROM fleets WHERE planet = ? AND tick > tick() - 24
+AND mission = 'Full fleet' AND name IN ('Main','Advanced Unit');
                                },undef,$c->user->planet);
                        $fleetupdate = 0 unless defined $fleetupdate;
                }
@@ -214,8 +219,8 @@ sub end : ActionClass('RenderView') {
        $birthdays->execute;
        $c->stash(birthdays => $birthdays->fetchall_arrayref({}));
 
-       if ($c->res->status == 200){
-               $c->flash(referrer => $c->req->path);
+       if ($c->res->status == 200 || $c->req->method eq 'GET'){
+               $c->session->{referrer} = $c->req->path;
        }
 }