UseMuffin / Footprint

CakePHP plugin to allow passing currently logged in user to model layer.
MIT License
95 stars 23 forks source link

API Prefix routing error #60

Closed spacebiscuit closed 5 years ago

spacebiscuit commented 5 years ago

When using an API prefix routing the plugin doesn't seem to work:

SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'user_id' cannot be null

My table class:

$this->addBehavior('Muffin/Footprint.Footprint', [
            'events' => [
                'Model.beforeSave' => [
                    'user_id' => 'new',
                ]   
            ]
        ]);

My ApiAppController:

namespace App\Controller\Api;

use App\Controller\AppController;
use Cake\Event\Event;
use Muffin\Footprint\Auth\FootprintAwareTrait;
use Cake\Core\Exception\Exception;

class ApiAppController extends \App\Controller\AppController {

    use \Crud\Controller\ControllerTrait;
    use FootprintAwareTrait;

Without the API prefix routing the user_id is saved and the error does not fire.

spacebiscuit commented 5 years ago

I was missing parent::initialize()in my apiappcontroller