jeffp / wizardly

create a functioning wizard for any model in three steps
http://github.com/jeffp/wizardly-examples
MIT License
131 stars 16 forks source link

Problems mixing wizardly with authlogic #3

Open matellis opened 15 years ago

matellis commented 15 years ago

I'm using authlogic for my authentication plugin and have a three step wizard setup that sets up a a user that is acting as authentic with authlogic doing stuff behind the scenes like encrypting passwords, etc.

When the final step is completed and the FINISH button is pressed the User object is written to the database but it looks like authlogic hasn't had a chance to do it's stuff as various fields it populates are nil. The result is this error:

Mysql::Error: Column 'crypted_password' cannot be null: INSERT INTO 'users'

The bottom of the code stack looks like this:

(eval):52:in 'complete_wizard'
(eval):110:in 'step3'

After a lot of digging the crypted_password field is not being set as I've protected it in my model to prevent people setting up users using a URL (see http://b.lesseverything.com/2008/3/11/use-attr_protected-or-we-will-hack-you ).

Wizardly uses mass assignment to submit my final record and this conflicts with using attr_protected on some important user attributes. Can anyone recommend a work round so I can use wizardly, authlogic and attr_protected? I'm thinking - maybe a callback method that I can use in place of mass assignment so I can poke in the values into a new User object myself?