I have a controller which process uploaded files by uploadify. The problem is that the Auth::check('default')
always return null. So I can't check if the user is logged in and authorized to upload.
class UploadController extends \app\controllers\AppController {
// this works perfect, the auth configuration is printed out
public function index() {
$auth = Auth::check('default');
print_r($auth);
}
// this doesnt work
public function uploadify() {
$auth = Auth::check('default');
print_r($auth); // always empty!
...
}
}
The uploadify
function is called via uploadify. I tried to trace the problem back but I ended in StaticObject::_filter
where the following if statement returns true:
if (!isset(static::$_methodFilters[$class][$method])) {...}
This differs from the call of index()
where the if-statement isn't executed. But I have no idea what's done there.
Thx to #li3 i got this work with http://www.uploadify.com/forums/discussion/43/using-sessions-tricking-basic-authentication/p1
In the view i used the scriptData:
'scriptData': { 'PHPSESSID': '<?php echo(session_id()); ?>'},
and in the Controller:
public function uploadify() {
$id = $_POST['PHPSESSID'];
session_id($id);
session_start();
$auth = Auth::check('default');
if ($auth == null) {
return $this->response->status = array('code' => 401, 'message' => 'Unauthorized');
}
...
}