Reset password with custom ruby file

This is explicitly not part of the steps.

There is a difference between creating a user field with that name, and having a custom field with that name. So the hash is being stored in the wrong place.

The problem is that I think that the latter (a custom field) is not accessible using the API.
I think the best way forward is to have some custom once-off code that moves the content of the user field to the actual custom field.

(I considered changing the plugin so it looks at the user field as well but I think surfacing those hashes to the user interface is a security risk, so not going to do that).

This will work, run it from a rails console (tagging you so you see the edit @Hitesh_Sharma )

ufkey = "user_field_#{UserField.find_by(name: 'import_pass').id}"
User.all.each do |u|
  if u.custom_fields.key?(ufkey)
    u.custom_fields[:import_pass] = u.custom_fields[ufkey]
    u.custom_fields.delete(ufkey)
    u.save_custom_fields
  end
end
2 Likes