Handle has_secure_password field

Hi all,

Feature(s) impacted

User creation

Observed behavior

image

This field is not supposed to be modified. I can’t create a new user as password and password_confirmation fields are required when resorting to has_secure_password on user model.

Expected behavior

I would prefer to have one password and password_confirmation fields like Rails Admin do. It’s the standard implementation of has_secure_password with a password_digest field in database.

Context

  • Project name: Lakaa
  • Team name: Lakaa
  • Environment name: Production
  • Agent type & version: forest_liana (7.4.5)

Hi @adrilef,

Yes we do not support it natively. We pushed your request on our productboard.

In the meantime, you can make it work by using smart fields. You’ll need to create a smart field:

class Forest::User
  include ForestLiana::Collection

  collection :User

  set_password = lambda do |user_params, password|
    user_params[:password] = password

    # Returns a hash of the updated values you want to persist.
    user_params
  end

  field :password, type: 'String', set: set_password do
    object.password_digest ? :filled : nil
  end

  set_password_confirmation = lambda do |user_params, password_confirmation|
    user_params[:password_confirmation] = password_confirmation

    # Returns a hash of the updated values you want to persist.
    user_params
  end

  field :password_confirmation, type: 'String', set: set_password_confirmation do
    object.password_digest ? :filled : nil
  end
end

Something like that might work, let me know

Hi @vince
Thanks for your prompt answer. I’ll try this out !