Log message #4261464

# At Username Text
# Apr 19th 2021, 00:28 davinci Trying to use `$http->get()` , which seems fine, but when I try to use the suggested `$response->body()`, I get this error: `Call to undefined method Cake\Http\Client\Response::body()`
# Apr 18th 2021, 21:46 kevin.pfeifer i guess the solution from cakedc/users is the best way https://github.com/CakeDC/users/blob/master/src/View/Helper/AuthLinkHelper.php
# Apr 18th 2021, 20:07 kevin.pfeifer or do i have to check that myself before in the controller and pass that data to the view
# Apr 18th 2021, 20:06 kevin.pfeifer But keeping on the authorization plugin: Is there a way in the template to check if the current user is allowed to perform a specific action? In the “old” ACL days i remember doing something like ```$this->Acl->link(__('Edit'), ['action' => 'edit', $user->id])``` So there was a separate Acl Helper for the view.
# Apr 18th 2021, 17:18 kevin.pfeifer if so, i would highly recommend you to go through the authorization tutorial here and you will probably get how the whole auth system comes together https://book.cakephp.org/4/en/tutorials-and-examples/cms/authorization.html
# Apr 18th 2021, 17:17 kevin.pfeifer I have not yet used the CRUD plugin but do you have “normal” controller functions where you get into after calling a CRUD URL of your choice?
# Apr 18th 2021, 15:28 noel How can I use Authorization plugin with friends-of-cake/CRUD?
# Apr 18th 2021, 14:42 me1367 Ah okeay, thanks.
# Apr 18th 2021, 14:40 ndm @me1367 You cannot trigger `E_WARNING`, that's for PHP internal code, userland code can only trigger `E_USER_*`.
# Apr 17th 2021, 19:40 me1367 Quick question. When I inform the developer that a value is "wrong" (in my case an expiry of `0` or a negative value), would it be better practice to throw a `E_USER_WARNING` or `E_WARNING`?
# Apr 17th 2021, 11:49 isvyas You can use mailtrap too. https://mailtrap.io/
# Apr 16th 2021, 22:01 slackebot `$this->setTable('tablename')`.
# Apr 16th 2021, 22:01 ndm The join table and the target table would need to be in the same database in order for this to work with multiple connections, as they are both being retrieved together via joining. If the join table needs to be in a different DB, then your best chance is to modify the table name config of your table classes in case your DBMS supports cross DB communication, ie `$this->setTable('dbname.tablename')` instead of
# Apr 16th 2021, 21:58 ron.rattie well you have described what I have setup so far
# Apr 16th 2021, 21:55 kevin.pfeifer sorry, never done that/needed that till now but i guess you would have to 1. have both database connections set in your config/app_local.php and 2. somehow set the "non default" connection to be used inside your model where it should connect to the other database But i have no idea how
# Apr 16th 2021, 21:49 ron.rattie Is there any reason in Cakephp 4 that I wouldn't be able to have a relationship 'belongsToMany' involving a table in a different database? DB 1 Users -> DB 1 UsersOrganizations <- DB 2 Organizations
# Apr 16th 2021, 21:25 tyler.adam.lazenby thanks
# Apr 16th 2021, 21:21 kevin.pfeifer https://book.cakephp.org/4/en/controllers/middleware.html#skipping-csrf-checks-for-specific-actions
# Apr 16th 2021, 21:14 tyler.adam.lazenby would I disable csrf on a certain action (it needs to act like an endpoing for a web api web hook, and it is only available via post)
# Apr 16th 2021, 19:34 kevin.pfeifer i have not used that method yet, i “just” rebuild the app :)
# Apr 16th 2021, 19:33 kevin.pfeifer i have heard the rector method can be quite tricky to set up correctly but if you get it working, it automatically converts most of the stuff
# Apr 16th 2021, 19:32 kevin.pfeifer not that bad i would guess. Depends on how much custom functionality you have
# Apr 16th 2021, 19:29 jh 3.9 without any deprecation warnings, warnings, notices
# Apr 16th 2021, 19:29 jh In your experiences, how much pain is it to go from 3.9 to 4.0 or even 4.2?
# Apr 16th 2021, 16:53 kevin.pfeifer a controller method should only be used to be shown as a seperate url with a seperate template. So if you have functionality that you need in your controller and your component then I would create a Utility Class.
# Apr 16th 2021, 16:53 greg138 Simple answer: don't. Pull that shared functionality into a separate utility class.
# Apr 16th 2021, 16:52 luizcmarin I understand. Perhaps my approach is not correct. I will think a little more. But already to take a very boring question: Being inside a function in a component, how do I call a method from another controller?
# Apr 16th 2021, 16:47 greg138 I guess it depends... Are you expecting that if they have a page sitting open when the session expires, that page will show something about it? That would require JavaScript and an Ajax ping happening regularly. Or is it a page that is available to everyone but has extra details or options if they're logged in? That would be a harder situation; it won't redirect them to login because authorization doesn't require it.
# Apr 16th 2021, 16:37 luizcmarin @greg138 1. Yes, it is similar to what you sent me. 2. When the session expires due to inactivity, it is not redirecting to the login screen. Would it be a session configuration problem?
# Apr 16th 2021, 15:53 greg138 1. If the session expires, then the standard authentication and authorization should recognize that they do not have access to the thing they're trying to access, and redirect to the login automatically. 2. This part sounds exactly like the link that I gave?
# Apr 16th 2021, 15:44 luizcmarin @greg138 1. the user often lets the session expire due to inactivity and some variables that I load expire. So I need him to come in again to recharge them. 2. In other cases, I want him to identify himself again to allow or disallow an action, a launch, or something else.
# Apr 16th 2021, 15:19 greg138 Is this the same general question? https://discourse.cakephp.org/t/check-credentials-with-authentication-module-without-logging-in/9255
# Apr 16th 2021, 15:19 greg138 What do you mean by "force a new login"?
# Apr 16th 2021, 15:01 luizcmarin Of course, you know a better way, perhaps by calling authentication, but I have not been able to find HOW to do this.
# Apr 16th 2021, 15:00 slackebot _*//! ??? HOW TO FORCE A NEW LOGIN HERE?*_` `if ($loginOk == true {` `...` `} else {` `...` `}` `}`
# Apr 16th 2021, 15:00 luizcmarin The tips are good, believe me. I've been reading about it all morning, but ... I will exemplify my role. Perhaps it will be easier to express myself. In a component I have several functions that will require a re-login. Well I haven't been able to call the login function directly ... and that sums up my problem. `public function myExample ($ type = 'U'): bool` `{` `$loginOk = $ this-> Users-> login ();
# Apr 16th 2021, 14:50 greg138 Not much documentation about this, but https://book.cakephp.org/authentication/1/en/migration-from-the-authcomponent.html#checking-identities mentions the `setIdentity` function, which I think is what you'd use for this.
# Apr 16th 2021, 14:45 luizcmarin thanks @kevin.pfeifer
# Apr 16th 2021, 14:39 kevin.pfeifer don't know if there is an "easier", ready made function or config for that behavior in the authentication plugin though
# Apr 16th 2021, 14:38 nayakvradhit @greg138 I found out the cause of css and js file not loading as it was not reffering to correct path in index.html file thanks for ur help yesterday
# Apr 16th 2021, 14:35 kevin.pfeifer I would do something like that 1. Check in your "need login" function if user is logged in 2. If not, do a normal redirect to /users/login including a GET parameter with current URL like that `/users/login?redirect=some-url` 3. After User has logged in check if the `redirect` GET parameter is set and redirect to that url to go back where you where before the login