Incorporating Devise Authentication into an already existing user structure?

后端 未结 3 1335
南方客
南方客 2021-02-06 08:38

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

3条回答
  •  粉色の甜心
    2021-02-06 08:55

    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.

提交回复
热议问题