Sha256: 95469cd40c2e09874226c1d7eff0fd5e1a6b3f9bbf048beb98f056a975799d26

Contents?: true

Size: 985 Bytes

Versions: 1

Compression:

Stored size: 985 Bytes

Contents

include_set Abstract::AccountField

def history?
  false
end

def ok_to_read
  own_account? || super
end

event :encrypt_password, :store, on: :save, changed: :content do
  salt = left&.salt
  self.content = Auth.encrypt content, salt

  # errors.add :password, 'need a valid salt'
  # turns out we have a lot of existing account without a salt.
  # not sure when that broke??
end

event :validate_password, :validate, on: :save do
  return if content.length > 3

  errors.add :password, t(:account_password_length)
end

event :validate_password_present, :prepare_to_validate, on: :update do
  abort :success if content.blank?
end

view :raw do
  t :account_encrypted
end

format :html do
  view :core, wrap: :em do
    render_raw
  end

  view :input do
    card.content = ""
    password_field :content, class: "d0-card-content", autocomplete: autocomplete?
  end

  def autocomplete?
    return "on" if @parent && @parent.card.name == "*signin+*account" # HACK

    "off"
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
card-mod-account-0.14.2 set/right/password.rb