Skip to content

Instantly share code, notes, and snippets.

@tristar500
Created February 14, 2013 23:04
Show Gist options
  • Save tristar500/4957216 to your computer and use it in GitHub Desktop.
Save tristar500/4957216 to your computer and use it in GitHub Desktop.
Laravel 4 base controller authentication
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