I have made a simple system for a remember-me functionality. Now I want to start using it in other applications as well so turning it into a plugin seems the most appropriate solution. I looked at the documentation about plugin creation and the examples they give are different from what I’m looking for, hence I’d like some advice.
The functionality looks like this right now:
- In
AppController->initialize()
a custom method is called (AppController->checkToken()
) that logs a user is if it isn’t yet and a valid token is present. - In
UsersController->login()
a custom method is called (UsersController->makeToken()
) that checks if the remember-me option was checked and creates a key-token pair if so.
Now where would I put that code in a plugin? Would I create a class for it? But then who would own the class instance? And I would like to avoid having to load models unnecessarily.