I'm building a Symfony 1.4 project that is using sfDoctrineGuardPlugin for users/authentication. I have a field on my user table named "access_token" that I would like to populate with an auto-generated value upon user registration. I see that for registration, the sfGuardRegisterForm
is used for validation. Unfortunately, when I run ./symfony doctrine:build-forms
from the command line, this form doesn't appear to be extended, meaning that I can't generate an access token there without editing the plugin.
Alternatively, I was thinking of modifying the sfRequest
parameters such that I manually set the "access_token" value before attempting to validate via this form. However, since I'm allowing users to register both by a frontend application as well as an API application, this means that I would have to make sure I manually stuff this parameter value in both places, which seems inefficient. However, perhaps that is actually the right way to go, and trying to modify the form is not ideal.
Any input/suggestions? Would anyone do anything different than the ideas I have listed here?
Edit: I've already create a public static method on my sfGuardUser
model named generateAccessToken
, which returns the value. I'm just trying to figure out the best place to call this in my project's code.
sfDoctrineGuardPlugin does not provide user registration functionality. This why you have to implement it on your own. So, in your controller you can populate a field just the way it's being done with symfony:
And the
access_token
widget should be an instance ofsfWidgetFormInputHidden
. Hope this helps.