Sha256: fc84010b163874fd1cc028ceecf6fdd30661510e03ddc3965cfc4e3b668dd9b3

Contents?: true

Size: 1006 Bytes

Versions: 8

Compression:

Stored size: 1006 Bytes

Contents

include_set Abstract::AccountField

assign_type :phrase

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

8 entries across 8 versions & 1 rubygems

Version Path
card-mod-account-0.15.6 set/right/password.rb
card-mod-account-0.15.5 set/right/password.rb
card-mod-account-0.15.4 set/right/password.rb
card-mod-account-0.15.3 set/right/password.rb
card-mod-account-0.15.2.pre1 set/right/password.rb
card-mod-account-0.15.1.1 set/right/password.rb
card-mod-account-0.15.1 set/right/password.rb
card-mod-account-0.15.0 set/right/password.rb