Log message #4054583

# At Username Text
# Jul 20th 2017, 14:09 mccp the error says it's null
# Jul 20th 2017, 14:09 hmic you said its NULL
# Jul 20th 2017, 14:09 mccp but the id i give it exists in database.
# Jul 20th 2017, 14:04 hmic you are saving to an entity that does not exist
# Jul 20th 2017, 14:04 mccp can anyone help me why i'm getting record not found in table with primary key [NULL] when the association jointype is left and null is allowed.
# Jul 20th 2017, 13:40 hmic welcome
# Jul 20th 2017, 13:36 Ecorce Yeeeeeees, problem solved. Thx hmic.
# Jul 20th 2017, 13:26 hmic but an unauthorized request would be handled like you setup Auth anyways, so thats good already. maybe you could add a flashmessage to be shown and return false;
# Jul 20th 2017, 13:25 hmic Ecorce, you could. but thats not what it is meant for really. NotAuthorizedException e.g.
# Jul 20th 2017, 13:24 Ecorce (to provide a useful message)
# Jul 20th 2017, 13:24 awi how can i put the download attribute into HtmlHelper::link()? Is it some sort of option?
# Jul 20th 2017, 13:24 Ecorce Can isAuthorized return an exception?
# Jul 20th 2017, 13:17 mccp here is a gist https://gist.github.com/mccp/8b135e5556c57671ab17c756c9af34fa
# Jul 20th 2017, 13:17 mccp Hi, I'm trying to save my Listing entity that is associated with Properties entity by belongsTo which is also associated with a PropertyCategories entity by belongsTo. I've set the joinType between Propertiess and PropertyCategories to left. When a null value is assigned to $listing->property->property_category_id and called with $listingTable->save($listing), I get a Record not found in table property_categories with primary key [NULL
# Jul 20th 2017, 13:17 hmic second, you add check if a user is logged in in the Controller::isAuthorized($user) returning true if you find a user in the session (well: return (bool)$user; or return array_key_exists('id', $user); or something)
# Jul 20th 2017, 13:15 hmic so first: you allow all actions that should be accessible without beeing logged in in the Controller::initialize() with Auth->allow()
# Jul 20th 2017, 13:14 Ecorce I've just the loginAction specified and that's all in the config
# Jul 20th 2017, 13:14 Ecorce Yes, it's already done : "authorize' => ['Controller']
# Jul 20th 2017, 13:14 hmic "authorize" => "Controller" i think
# Jul 20th 2017, 13:13 hmic you need to specify in the auth config
# Jul 20th 2017, 13:13 Ecorce hmic, that'd be perfect to me, but... Auth don't want to look at my isAuthorized function, he redirects to loginAction first -_-
# Jul 20th 2017, 13:12 awi hm. Does htmlHelper->link support the download tag? https://www.w3schools.com/tags/att_a_download.asp
# Jul 20th 2017, 13:00 hmic 3 lines of code there
# Jul 20th 2017, 13:00 hmic you can put that in the appcontroller too and return true if a user exists.
# Jul 20th 2017, 12:59 hmic you need to implement an isauthorized method
# Jul 20th 2017, 12:59 hmic you cant if you want to use allow, allow does just allow an action to be accessed like before (without auth beeing enabled), nothing else.
# Jul 20th 2017, 12:58 Ecorce nop, I juste need to check if user is connected with Auth, no more
# Jul 20th 2017, 12:58 hmic if you want to decide on a user basis, this is not authentication, but authorization and you would need an isauthorized in the controller (and set controllerauthorization in the auth config), like i said before
# Jul 20th 2017, 12:57 hmic you need to allow before auth has run!
# Jul 20th 2017, 12:57 hmic of course it is
# Jul 20th 2017, 12:49 Ecorce I just want to start the component, I don't want him to forbid at first... I've tried : unauthorizedRedirect => false, but, no better
# Jul 20th 2017, 12:48 Ecorce I've tried to move the allow inside initialize for each Controller, but then again, $this->Auth->user() is empty
# Jul 20th 2017, 12:41 adriencs thanks @dereuromark
# Jul 20th 2017, 12:41 hmic but use controller authorization rather and implement an isauthorized function, or use the controller initialize to Auth->allow()
# Jul 20th 2017, 12:41 dereuromark you can customize either the relation and the attribute, or resolve as you did by using a more unique name for the select alias
# Jul 20th 2017, 12:40 dereuromark job is also the related attribute for Jobs table in your main table here. thats why it probably collides @adriencs
# Jul 20th 2017, 12:40 hmic you actually should not allow from there anyways
# Jul 20th 2017, 12:40 hmic Ecorce, because auth did run before, like you specified!
# Jul 20th 2017, 12:03 Ecorce Hmm, loginAction is called everytime now, no matter $this->Auth->allow() (in BeforeFilter of the Controllers)
# Jul 20th 2017, 11:51 Ecorce https://book.cakephp.org/3.0/en/controllers/components/authentication.html#deciding-when-to-run-authentication
# Jul 20th 2017, 11:50 Ecorce (not authCheckIn) :p