I have two tables, users
and tokens
.
Each user have a activated
field and each token have the {id, token, user_id, created}
fields.
The way the app should work is: On the creation, the app will -
- make sure that the
activated
field is empty (to avoid manipulations to the submitted data). - a token will be created in the
tokens
table.
On update, the app will -
- NOT create a new token.
- NOT allow an update of any kind to the
activated
field. - check if a new email has been submitted, and if so: will create a new token and set the
activated
field to false.
I know how to activate the account through the controller and how to setup the router for that.
What I need is mainly the model configuration.
For example:
I think that the token creation should be done in the afterSave
method, so - how do I determine if the method is called by an update or by a create operation?
Thanks for any help