]> ruin.nu Git - ndwebbie.git/commitdiff
Use sessions for redirect to previous page instead of referer header
authorMichael Andreen <harv@ruin.nu>
Sun, 2 Nov 2008 12:08:32 +0000 (13:08 +0100)
committerMichael Andreen <harv@ruin.nu>
Sun, 2 Nov 2008 12:08:32 +0000 (13:08 +0100)
lib/NDWeb/Controller/CovOp.pm
lib/NDWeb/Controller/Forum.pm
lib/NDWeb/Controller/Raids.pm
lib/NDWeb/Controller/Root.pm

index ea67978ef9fd8037de2d9baf24d8bc1674bef33c..71ea3082823427db2022ce9a4dfb38edf7b79c06 100644 (file)
@@ -42,7 +42,7 @@ sub marktarget : Local {
        my $update = $dbh->prepare(q{INSERT INTO covop_attacks (uid,id,tick) VALUES(?,?,tick())});
        $update->execute($c->user->id,$target);
 
-       $c->res->redirect($c->req->referer);
+       $c->forward('/redirect');
 }
 
 sub list : Private {
index d08bb6150ac9a7bdb7bb5a2c953435f13210c3a4..f4fa3c0abd74dd36411e6db572161b3eaf50476c 100644 (file)
@@ -277,7 +277,7 @@ sub markBoardAsRead : Local {
                $c->forward('markThreadAsRead',[$thread->{ftid}]);
        }
        $dbh->commit;
-       $c->res->redirect($c->req->referer);
+       $c->forward('/redirect');
 }
 
 sub markThreadAsRead : Private {
index 410d42d0f29fce96d795c71e502ff2c85ee0a8a0..f2bfa0a0fc526f9d4159a0b46eb3582f60ebbaa6 100644 (file)
@@ -433,7 +433,7 @@ sub open : Local {
        $c->forward('log',[$raid, "BC opened raid"]);
        $c->model->commit;
 
-       $c->res->redirect($c->req->referer);
+       $c->forward('/redirect');
 }
 
 sub close : Local {
@@ -445,7 +445,7 @@ sub close : Local {
        $c->forward('log',[$raid, "BC closed raid"]);
        $c->model->commit;
 
-       $c->res->redirect($c->req->referer);
+       $c->forward('/redirect');
 }
 
 sub remove : Local {
@@ -457,7 +457,7 @@ sub remove : Local {
        $c->forward('log',[$raid, "BC removed raid"]);
        $c->model->commit;
 
-       $c->res->redirect($c->req->referer);
+       $c->forward('/redirect');
 }
 
 sub showcoords : Local {
@@ -469,7 +469,7 @@ sub showcoords : Local {
        $c->forward('log',[$raid, "BC released coords"]);
        $c->model->commit;
 
-       $c->res->redirect($c->req->referer);
+       $c->forward('/redirect');
 }
 
 sub hidecoords : Local {
@@ -481,7 +481,7 @@ sub hidecoords : Local {
        $c->forward('log',[$raid, "BC hid coords"]);
        $c->model->commit;
 
-       $c->res->redirect($c->req->referer);
+       $c->forward('/redirect');
 }
 
 sub create : Local {
index 8a6ab6abce00df8223909fbd281a55399fcad48f..05f2ef8fe258801968c6099b47a8dec127d7ece1 100644 (file)
@@ -60,10 +60,10 @@ sub login : Local {
                $log->execute($c->user->id,$c->req->address
                        ,$country,$c->sessionid,$remember);
 
-               my $ref = $c->req->referer;
-               $ref =~ s/^http:/https:/ unless $c->debug;
-               $c->res->redirect($ref);
+               $c->forward('redirect');
                return;
+       } elsif ($c->req->method eq 'POST'){
+               $c->res->status(400);
        }
 }
 
@@ -142,7 +142,11 @@ sub auto : Private {
        }else{
                $c->stash(UID => -4);
        }
+}
 
+sub redirect : Private {
+       my ($self, $c) = @_;
+       $c->res->redirect($c->uri_for('/'.$c->flash->{referrer}));
 }
 
 sub access_denied : Private {
@@ -161,6 +165,10 @@ Attempt to render a view, if needed.
 sub end : ActionClass('RenderView') {
        my ($self, $c) = @_;
 
+       if ($c->res->status == 302){
+               return;
+       }
+
        my $dbh = $c ->model;
 
        if (scalar @{ $c->error } ){
@@ -205,6 +213,10 @@ sub end : ActionClass('RenderView') {
                });
        $birthdays->execute;
        $c->stash(birthdays => $birthdays->fetchall_arrayref({}));
+
+       if ($c->res->status == 200){
+               $c->flash(referrer => $c->req->path);
+       }
 }
 
 =head1 AUTHOR