Class: Ezframe::PasswordType
Instance Attribute Summary
Attributes inherited from TypeBase
#attribute, #error, #parent
Instance Method Summary
collapse
Methods inherited from TextType
#db_type, #normalize, #value=
Methods inherited from TypeBase
#db_type, get_class, #key, #label, #make_error_box, #multi_inputs?, #no_edit?, #no_view?, #normalize, #type, type_name, #use_view_format, #validate, #value, #value=, #view
Constructor Details
#initialize(attr = nil) ⇒ PasswordType
Returns a new instance of PasswordType.
285
286
287
288
|
# File 'lib/ezframe/column_type.rb', line 285
def initialize(attr = nil)
super(attr)
@attribute[:no_view] = true
end
|
Instance Method Details
310
311
312
313
|
# File 'lib/ezframe/column_type.rb', line 310
def db_value
crypt = BCrypt::Password.create(@value)
return crypt.to_s
end
|
#encrypt_value(val) ⇒ Object
290
291
292
293
|
# File 'lib/ezframe/column_type.rb', line 290
def encrypt_value(val)
crypt = BCrypt::Password.create(val)
return crypt.to_s
end
|
300
301
302
303
304
305
306
307
308
|
# File 'lib/ezframe/column_type.rb', line 300
def form(opts = {})
return nil if no_edit? && !opts[:force]
key = self.key
key ="#{key}#{opts[:key_suffix]}" if opts[:key_suffix]
h = Ht.input(type: "password", name: key, label: @attribute[:label], value: "")
h[:class] = @attribute[:class] if @attribute[:class]
h[:after] = make_error_box(key)
return h
end
|
#value_equal?(value_from_db, new_value) ⇒ Boolean
295
296
297
298
|
# File 'lib/ezframe/column_type.rb', line 295
def value_equal?(value_from_db, new_value)
crypt = BCrypt::Password.new(value_from_db)
return crypt == new_value
end
|