5
0
Fork 0
mirror of https://0xacab.org/sutty/sutty synced 2024-05-19 12:30:49 +00:00

feat: implementar campo de tipo password #8342

This commit is contained in:
f 2022-11-01 13:17:03 -03:00
parent 6c7ddb082d
commit 3d8c9b4031
5 changed files with 42 additions and 0 deletions

View file

@ -0,0 +1,25 @@
# frozen_string_literal: true
# Almacena una contraseña
class MetadataPassword < MetadataString
# Las contraseñas no son indexables
#
# @return [boolean]
def indexable?
false
end
private
alias_method :original_sanitize, :sanitize
# Sanitizar la string y generar un hash Bcrypt
#
# @param :string [String]
# @return [String]
def sanitize(string)
string = original_sanitize string
::BCrypt::Password.create(string).to_s
end
end

View file

@ -0,0 +1,6 @@
%tr{ id: attribute }
%th= post_label_t(attribute, post: post)
%td{ dir: dir, lang: locale }
= metadata.value
%br/
%small= t('.safety')

View file

@ -0,0 +1,7 @@
.form-group
= label_tag "#{base}_#{attribute}", post_label_t(attribute, post: post)
= password_field base, attribute, value: metadata.value,
dir: dir, lang: locale,
**field_options(attribute, metadata)
= render 'posts/attribute_feedback',
post: post, attribute: attribute, metadata: metadata

View file

@ -414,6 +414,8 @@ en:
attribute_ro:
file:
download: Download file
password:
safety: Passwords are stored safely
show:
front_matter: Post metadata
submit:

View file

@ -422,6 +422,8 @@ es:
attribute_ro:
file:
download: Descargar archivo
password:
safety: Las contraseñas se almacenan de forma segura
show:
front_matter: Metadatos del artículo
submit: