Log message #4261440

# At Username Text
# 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
# Apr 16th 2021, 14:20 luizcmarin Hi. I would like to force the login within some functions for security reasons. How can I call / users / login from a component? (I installed the Authentication plugin correctly from the cookbook)
# Apr 15th 2021, 22:12 rightscoreanalysis thanks!
# Apr 15th 2021, 20:14 admad @rightscoreanalysis that's basically authorization, not authentication. Keep a keep which indicated whether the user has completed his profile or not and based on it's values redirect to page for completing their profile.
# Apr 15th 2021, 20:12 admad Router is for matching what you need, not want you want to discard/filter out. All the crap URLs would end up not matching any route and an exception being thrown.
# Apr 15th 2021, 19:09 marek.sebera @admad also disregarding the malware-blocking intent, being able to match beginning of URL could be incredibly useful for cases, where the called URL does not need to (or cannot) follow standard pattern of `?param=val#hash` (i've already seen some obscure URLs in WS/SOAP handling/interop)
# Apr 15th 2021, 18:47 rightscoreanalysis I can add logic I guess to redirect only when !profile.complete ... or is there a better otb way to do this... I don't want t re-invent the wheel
# Apr 15th 2021, 18:46 rightscoreanalysis @admad within the social auth plugin, when a user is successfully authenticated I want to re-direct them to a page where they can complete their profile..... I saw that there is a redirect url which can be configured, but if a user has already completed their profile and is logging in they shouldn't be redirected....
# Apr 15th 2021, 18:45 marek.sebera @admad that means touching the infrastructure, which I'd like to avoid, but yeah, indeed it's possible
# Apr 15th 2021, 18:13 admad why not just fail the request a webserver level?
# Apr 15th 2021, 18:09 marek.sebera Routing: If I want to handle any URL starting with "/index.html" eg. "/index.html::$data" (some malwarebot testing url), how should the route be written? Because neither `*` or `**` works without separator (ie. `/* or /**`) of url segments
# Apr 15th 2021, 17:49 nayakvradhit Yeah /var/www
# Apr 15th 2021, 17:13 admad you can just use Smtp transport and set the port to 1025, done. No change in php config needed as stated in it's readme.
# Apr 15th 2021, 17:11 richard thanks I’ll look into mailhog!
# Apr 15th 2021, 17:11 admad https://github.com/mailhog/MailHog
# Apr 15th 2021, 16:09 greg138 You mean `/var`, not `var`, I assume, or else none of it would work. It's not absolutely mandatory, it can work other ways, but this is by far the easiest. If pages are coming back correctly, just without the CSS and JS, then it's very close to right.
# Apr 15th 2021, 15:55 nayakvradhit Is it madatory to set the doc root to var/www/html/appname/app/webroot?
# Apr 15th 2021, 15:54 nayakvradhit And configured apache to run the app ipaddress/appname
# Apr 15th 2021, 15:53 nayakvradhit I copied old cakephp folder jnto new server
# Apr 15th 2021, 15:52 nayakvradhit Can you please tell me what I did is correct procedure or not?
# Apr 15th 2021, 15:51 greg138 That should rule out filename case sensitivity issues, at least. :)
# Apr 15th 2021, 15:50 nayakvradhit It was on linux itself but previously they were deployed onsite client itself but now for the new server upgrade they have been assigned to me
# Apr 15th 2021, 15:49 nayakvradhit Ok thanks
# Apr 15th 2021, 15:40 greg138 For future reference, these are all the sorts of details that it's useful to start with. "I've been asked to move a Cake 2 application that I didn't develop from a Windows server to Linux, and I'm having this problem..."