Преглед на файлове

Fix to redirect a user if they request a private function while not logged in

Michael Francis преди 14 години
родител
ревизия
dc189ba46f
променени са 2 файла, в които са добавени 11 реда и са изтрити 3 реда
  1. 4 1
      config/bootstrap/auth.php
  2. 7 2
      controllers/UsersController.php

+ 4 - 1
config/bootstrap/auth.php

@@ -123,7 +123,10 @@ Dispatcher::applyFilter('_callable', function($self, $params, $chain) {
         return $ctrl;
     }
 
-    //Otherwise, send them to the login page 
+    //Save the location they are going to
+	$value = array('controller' => $ctrl->request->controller, 'action' => $ctrl->request->action, 'args' => $ctrl->request->args);
+	Session::write('url', $value);
+    //Redirect them to the login page 
     return function() use ($request) {
         return new Response(compact('request') + array('location' => '/login'));
     };

+ 7 - 2
controllers/UsersController.php

@@ -319,9 +319,14 @@ class UsersController extends \lithium\action\Controller {
 				}
 				
 				//If the user was trying to go somewhere, redirect them there
-				if ($location != null)
+				$loc = Session::read('url');
+				if (isset($loc))
 				{
-					
+					Session::delete('url');
+					return $this->redirect(array('controller' => $loc['controller'],
+										  'action' => $loc['action'],
+										  'args' => $loc['args']
+										  ));
 				}
 				//Otherwise send them to the hompa				
 				return $this->redirect('Users::feed');