Log message #4263415

# At Username Text
# May 18th 2021, 08:37 neon1024 Is there a Cakefest talk on how these plugins work, as there are lots of new concepts here and they are not intuitive at all to my brain
# May 18th 2021, 08:36 neon1024 I am very confused that that Authorization plugin is actioning my request first, and throwing a 403. Regardless of Authentication, and it fails to redirect back to my login
# May 18th 2021, 08:09 rightscoreanalysis Currently I can save Order with related Users and Addresses, but Orders.address_id is not saved
# May 18th 2021, 08:08 rightscoreanalysis if I have Order which BelongsTo User and Address, and User has many Addresses, can do a single save to Order which will save the address_id back through to Order?
# May 18th 2021, 05:54 savant Wow cakephp is too powerful
# May 17th 2021, 23:55 rightscoreanalysis but what does that mean?
# May 17th 2021, 23:55 rightscoreanalysis an old cake2 project is not saveAssociated, when I debug the validation: ```array( 'Address' => array() )```
# May 17th 2021, 22:16 khalil @ndm nevermind! what you mentioned works perfectly, my issue was that I have multiple classes that extend AppController and a few classes underneath them, the inheritance wasn't done correctly, now everything is working fine! Thanks!
# May 17th 2021, 22:01 khalil Whenever I try to access $currency in the template, i get undefined variable currency
# May 17th 2021, 22:00 khalil And here's my AppController's beforeFilter: ```public function beforeFilter(EventInterface $event) { parent::beforeFilter($event); if(!$this->is('seller')) { $this->Flash->error('You are not allowed to access this location'); return $this->redirect('/'); } $currency = $this->Picked->currency(); $this->set('currency', $currency); $this->viewBuilder()->setLayout('my-shop'); }```
# May 17th 2021, 22:00 khalil Here's my AppController initialize method: ```public function initialize(): void { parent::initialize(); $this->loadComponent('Security'); $this->loadComponent('Picked'); }```
# May 17th 2021, 21:59 khalil I tried what you told me, and the variable is not accessible in the template files
# May 17th 2021, 21:59 khalil Hey @ndm
# May 17th 2021, 21:38 r.piel if it's Cake 3 you got an Entity with get(), try with setUser((array) $personeSesion)
# May 17th 2021, 21:37 blackjccl @ndm What do you mean
# May 17th 2021, 21:36 blackjccl @r.piel now my code is like this ```$personaSesion = $this->Persona->get($persona->id_persona); $this->Auth->setUser($personaSesion);``` and it follows the same error
# May 17th 2021, 21:34 r.piel i hope ^^
# May 17th 2021, 21:34 r.piel it could be for transition
# May 17th 2021, 21:33 ndm No no, very first things first is seeing the words "*plain text*" and "*password*" closer together than 12 kilometers and getting immediate PTSD :grimacing:
# May 17th 2021, 21:32 r.piel first remove [] in get
# May 17th 2021, 21:25 slackebot $this->redirect(['controller'=>'Evaluaciones','action'=>'instructions', $this->Auth->user('id_persona')]); }```
# May 17th 2021, 21:25 blackjccl ```$persona = $this->Persona->findByTokenStringAndEstado($tokenLogin,1)->first(); if($persona andand (new DefaultPasswordHasher())->check($this->Password->getPlaintText($persona->plain_text),$persona->password)){ $personaSesion = $this->Persona->get([$persona->id_persona]); $this->Auth->setUser($personaSesion); return
# May 17th 2021, 21:25 blackjccl Hello everyone can someone help me with this problem I get this error ```Argument 1 passed to Cake\Controller\Component\AuthComponent::setUser() must be of the type array, object given, called * @link http://book.cakephp.org/3.0/en/controllers/components/authentication.html#identifying-users-and-logging-them-in */ public function setUser(array $user)``` my code is the following
# May 17th 2021, 21:16 khalil That was really helpful
# May 17th 2021, 21:16 khalil Thanks @ndm I'll give it a try now, I'll let you know how it goes
# May 17th 2021, 20:49 ndm But cells should inherit the current request object.
# May 17th 2021, 20:48 ndm You don't even need to leave your component, it can can access the controller from within it. But sure, you manually bridge things from the controller too. In any case, view variables are available in all templates, except in cells I think.
# May 17th 2021, 20:42 khalil I actually didn't know that, let me give it a try, thanks a lot
# May 17th 2021, 20:42 khalil @ndm thanks! You mean if I set a view variable in appcontroller's beforeFilter for example, it can accessed in any template?
# May 17th 2021, 20:35 ndm Components have access to the controller, so you could for example set a view variable, or a request attribute.
# May 17th 2021, 20:26 slackebot use it in views and controllers, what would be the best approach in that case?
# May 17th 2021, 20:26 khalil Now the $currency variable before being set, I'm doing a lot of logic, so I currently have it in a custom component (I check if the user is logged in and pull the currency from his account, if not, I check if there is a cookie "currency" saved and return it, if not, I convert his ip to his currency, and I save it in a cookie and return the value, I don't want to duplicate this logic in a helper and in a component in order to
# May 17th 2021, 20:24 khalil The issue I'm facing, is that I want to access this currency everywhere, literally everywhere, in the views, templates, components, and controllers
# May 17th 2021, 20:24 khalil Everything is set for the multiple currencies conversion etc.. But what I'm trying to do is, even if the user is not logged in, I'm converting the site currency to their local currency (mapping ips to countries to currency to conversion rate) This is also working perfectly
# May 17th 2021, 20:22 khalil I'm building an ecommerce website that supports multiple currencies
# May 17th 2021, 20:22 khalil I have a quick question more on the structure side of things in Cake
# May 17th 2021, 20:22 khalil Hello guys!
# May 17th 2021, 19:28 kevin.pfeifer basically: what do you want to achieve with that function ,:)
# May 17th 2021, 19:27 kevin.pfeifer ok well there are many ways to set it, i was just rememberg the way via controller but it can be off course changed in the view as well
# May 17th 2021, 19:25 kevin.pfeifer but setting the layout should happen in the controller (as far as I remember, haven't used it very often)
# May 17th 2021, 19:25 kevin.pfeifer basically any custom functions you want to use in your template can be added to `src/View/AppView.php` and are avaialbe in your templates file via `$this->myCustomFunction()`