I have a Rails 3.1.3 application that uses devise to authenticate users and software - removes them with acts_as_paranoid . I want the accounts to be restored during password recovery, user subscription and login, so if they provide a deleted email, I grab this account, make it live again, and then proceed (password recovery or login )
But in the Users::SessionsController#create action, after deleting the user, he receives an Unauthorized error (but now the user should be visible). The code:
def create # Take into account acts_as_paranoid deleted users resource = resource_class.only_deleted.find_by_email(params[resource_name][:email]) resource.undelete! if resource resource = warden.authenticate!(:scope => resource_name, :recall => "#{controller_path}#new") set_flash_message(:notice, :signed_in) if is_navigational_format? sign_in(resource_name, resource) respond_with resource, :location => after_sign_in_path_for(resource) end
If I add a call to resource.reload after deletion, it will not change anything. And if I log into the system again, the user will be properly signed, as he was restored in a previous attempt.
Why is this happening? How can I restore it and register in a single create call?
TuteC Jan 16 2018-12-21T00: 00Z
source share