Closed acjbizar closed 6 months ago
@acjbizar Have you tried to overwrite the method LoginComponent::updateLastLogin
witha a custom component?
https://github.com/CakeDC/users/blob/33af43401e2fab89b37175d6cdc3c3720ac6d14d/src/Controller/Component/LoginComponent.php
'Auth.FormLoginFailure.component' => 'MyLoginB',
( https://github.com/CakeDC/users/blob/33af43401e2fab89b37175d6cdc3c3720ac6d14d/Docs/Documentation/Authentication.md#handling-login-result )
@acjbizar Have you tried to overwrite the method
LoginComponent::updateLastLogin
witha a custom component?
… Oh, wow. That was a lot easier than what I was trying to do. Thanks!
I still think moving this thing to some sort of configuration would be a nice thing to have, but this is definitely workable for my case. Thanks again.
A config do disable it should not be a problem, feel free to send a pull request, by default the logic would not be disabled.
@rochamarcelo check this cake4: https://github.com/CakeDC/users/pull/1068 cake5: https://github.com/CakeDC/users/pull/1069
Changes merged
Thank You.
The
last_login
thing is nice, but I now have a situation where I have to connect to an external database that I can’t do migrations on. I got everything working, except thelast_login
upgrade it tries to do when logging in. In an attempt to overrule the login rules, I went down a rabbit hole of custom controller, trait, component, component loader … duplicating more and more code, making it much harder to maintain.I think it would be better if we could just flag a
last_login
option inusers.php
like'last_login' => false
. Even better, would probably to move it to its own class that then can be overridden explicitly, in a smililar way we handle other things like password hashers. The database I’m connecting to does have another field that takes a timestamp and does basically the same thing. (Though I could use a custom behavior to do that if the defaultlast_login
could just be disabled.)