in my cakephp app with custom auth implementation (see here) i would like to check the auth of a user in the beforefilter method and if he/she is not authenticated i would like to manually render an error page and quit. My problem here is that it seems the auth object gets only filled with data AFTER the action call to an action which require auth. i would need to access auth data in my beforefilter function. how to achieve this? if i try to access it auth->user() it returns NULL, loggedIn() returns always false (because there is no data, makes sense)
There's no need to check yourself whether a user is authenticated and show error page. Just add a
unauthenticated() method to your custom authenticate class like the BasicAuthenticate class does (without setting the headers). The error handler using the exception renderer will generate appropriate error page.