Created
February 14, 2013 23:04
-
-
Save tristar500/4957216 to your computer and use it in GitHub Desktop.
Laravel 4 base controller authentication
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class BaseController extends Controller { | |
public function __construct() | |
{ | |
// controllers in the array have to be authenticated before they can be viewed | |
if(in_array( Request::segment(1), array('job','journal','user')) ) | |
{ | |
echo 'This page needs to be authenticated'; | |
echo '<p>'; | |
$this->beforeFilter('auth'); | |
} | |
$this->beforeFilter('csrf', array('on' => 'post')); | |
$this->afterFilter('log', array('only' => | |
array('fooAction', 'barAction'))); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment