# |
Apr 19th 2017, 12:11 |
inoas |
its a small snipplet on a gist |
# |
Apr 19th 2017, 12:10 |
hmic |
inoas, its certainly ok to say: MIT, check licence.txt for details. but not mentioning anything sounds like a bad idea to me :p i could now make up a licence that forces everything that uses this code to adhere to it |
# |
Apr 19th 2017, 12:09 |
inoas |
updated for you hmic ;p |
# |
Apr 19th 2017, 12:08 |
inoas |
hmic: lol |
# |
Apr 19th 2017, 12:08 |
hmic |
inoas, you did not provide a licence.txt |
# |
Apr 19th 2017, 12:08 |
inoas |
hmic how would that be done with middleware then? I mean the passing down to the model |
# |
Apr 19th 2017, 12:07 |
inoas |
maybe you need something like this $this->_userModel = 'FlexiSystem.Users'; // Muffin/Footprint .. .if you users live ina plugin |
# |
Apr 19th 2017, 12:07 |
hmic |
all that crap goes away with middlewares, finally |
# |
Apr 19th 2017, 12:07 |
Junior |
allow me 2 minutes to paste |
# |
Apr 19th 2017, 12:07 |
Junior |
inoas, yes , i have that |
# |
Apr 19th 2017, 12:06 |
inoas |
in my case |
# |
Apr 19th 2017, 12:06 |
inoas |
and well $this->addBehavior('Muffin/Footprint.Footprint', ['events' => ['Model.beforeSave' => ['user_id' => 'always']]]); |
# |
Apr 19th 2017, 12:06 |
hmic |
obinoob, if you have a baked controller, just use the view function but pass the Auth->user('id') instead of $id. |
# |
Apr 19th 2017, 12:06 |
inoas |
https://gist.github.com/inoas/6152e91774ef3f303b6f4b567d726b19 |
# |
Apr 19th 2017, 12:06 |
inoas |
Junior: straight from my project |
# |
Apr 19th 2017, 12:05 |
obinoob |
ionas thank you |
# |
Apr 19th 2017, 12:05 |
Junior |
inside appController |
# |
Apr 19th 2017, 12:05 |
inoas |
muffin can do that for you (I think) |
# |
Apr 19th 2017, 12:05 |
Junior |
and use FootprintAwareTrait; |
# |
Apr 19th 2017, 12:05 |
inoas |
basically all you pass down is the user id |
# |
Apr 19th 2017, 12:05 |
Junior |
inoas i have added use Muffin\Footprint\Auth\FootprintAwareTrait; //https://github.com/UseMuffin/Footprint |
# |
Apr 19th 2017, 12:04 |
inoas |
obinoob: yeah |
# |
Apr 19th 2017, 12:03 |
Junior |
inoas, i had foreign keys, i had to drop them to see what happens :) |
# |
Apr 19th 2017, 12:02 |
obinoob |
ionas the finder would go in UserTable class I guess |
# |
Apr 19th 2017, 12:00 |
obinoob |
ionas that sound nice |
# |
Apr 19th 2017, 11:59 |
inoas |
you can build a finder that is only for the user himself, and pass down the user id from auth component when calling it from your controller |
# |
Apr 19th 2017, 11:58 |
inoas |
;p |
# |
Apr 19th 2017, 11:58 |
inoas |
middleware... urgh |
# |
Apr 19th 2017, 11:58 |
inoas |
the check for what he can do can either be controller or model domain |
# |
Apr 19th 2017, 11:58 |
inoas |
obinoob: IMHO depends. The check for which user is operating clearly is controller space |
# |
Apr 19th 2017, 11:57 |
inoas |
add debug() on top of $this->addBehavior |
# |
Apr 19th 2017, 11:56 |
inoas |
and you have to make sure your model where you use addBehavior is actually being used |
# |
Apr 19th 2017, 11:56 |
inoas |
then this line is important use Muffin\Footprint\Auth\FootprintAwareTrait; |
# |
Apr 19th 2017, 11:56 |
hmic |
can be a middleware very well as of 3.4 :D |
# |
Apr 19th 2017, 11:56 |
inoas |
Junior: first of all setup foreign keys so that user_id cannot ever be 0 or NULL ;) - just in case muffin does not work you do not accidentially save data without user ids :p |
# |
Apr 19th 2017, 11:56 |
hmic |
"code that would allow" - thats authorization |
# |
Apr 19th 2017, 11:49 |
obinoob |
I have a small doubt about where should i put code that allows a user to view only his own data entries I suppose that kind of logic would go in model instead of controller? |
# |
Apr 19th 2017, 11:39 |
Junior |
my createdby is saved as 0 instead of the actual user id |
# |
Apr 19th 2017, 11:29 |
Junior |
i am using https://github.com/UseMuffin/Footprint and my user is not loaded, i have followed the docs, any ideeas why? |
# |
Apr 19th 2017, 11:13 |
inoas |
_setIsPublished right |
# |
Apr 19th 2017, 11:12 |
inoas |
in which mutator/accessor would that happen? |