ankane / lockbox

Modern encryption for Ruby and Rails
MIT License
1.45k stars 68 forks source link

Devise Invalid Credentials after table name changed #178

Closed funkypierre closed 1 year ago

funkypierre commented 1 year ago

Hi there !

I recently changed a User table name, but I can't sign_in with any account now, just receiving the error "Invalid Credentials" under a 401 Unauthorized.

My steps :

I can access the records in console so I thought the migration went fine. Did I miss any step ?

Cheers :)

ankane commented 1 year ago

Hi @funkypierre, if you have any blind indexes on the model, you'll need to specify the key for those as well. There's not a key_table option yet, but you can use:

class User < ApplicationRecord
  blind_index :email, key: BlindIndex.index_key(table: "old_table", bidx_attribute: "email_bidx")
end
funkypierre commented 1 year ago

It worked instantly ! You saved my week ! I love you ! Thank you for the turbo quick response

ankane commented 1 year ago

Great, glad that fixed it! Also, added a key_table option in Blind Index 2.3.2 to make it possible to do:

class User < ApplicationRecord
  blind_index :email, key_table: "old_table"
end