I have a fully functional authentication system with a user table that has over fifty columns. It\'s simple but it does hash encryption with salt, uses email instead of usernam
i'd get rid of the :default => "" in your schema for email. devise puts a unique constraint on email by default, so you don't want defaults of empty string
I switched over an app from authLogic (I think) to Devise last year and my lessons were: - User table can stay - Rename columns to Devise standards, I'm sure this shouldn't be necessary, but unlike other authentication methodss, I didn't find a lib mapping file where I could add different db field names in as I have done with other authentication methods.
That was actually about it. I was really suprised about how little I needed to do. I think my hashes actually still worked or I changed to routine as directed in the instruction.
I use the 'admin' flag route with Devise so doing a sql conversion from whatever is used currently can do that.
I would also get rid of the default "" bit, I have a production app (not sure what authentication it uses, some base64 thing I think) and that looks like: t.string "EMAIL", :limit => 64, :null => false t.string "PASSWORD", :limit => 64, :null => false
The two main considerations I recall we faced when we did a similar thing were:
Database Migrations - rather than using the t.database_authenticatable
helpers, we wrote individual add_column and rename_column
statements, so that we didn’t run into any duplicate column or index errors that you’ve see, and so so that we could reuse our salt & hashed passwords within Devise without having to modify how the gem works.
The second, and larger, consideration, was that the hashing algorithm we used was not the same as any that Devise provided, and so we had to write our own encryptor class as subclass of Devise::Encryptors::Base
, and implement the digest function using our own logic. Finally, we configured Devise to use this encryptor by specifying it in the appropriate config/initializer file with config.encryptor = :our_own_algorithm
I hope this gives you enough to get you started.