Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

R-428 sivel2_gen. mejora seguridad en Devise #64

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions app/views/usuarios/_campo_encrypted_password.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<%= f.input :password %>
2 changes: 2 additions & 0 deletions config/locales/es.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ es:
errors:
format: "%{message}"
messages:
password:
password_strength: "La contraseña ingresada es muy débil"
accepted: "En '%{model}' debe aceptar '%{attribute}'"
blank: "En '%{model}' falta un valor para '%{attribute}'"
present: "En '%{model}' debe estar en blanco '%{attribute}'"
Expand Down
2 changes: 1 addition & 1 deletion lib/sip/concerns/controllers/usuarios_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ def lista_params_sip
:idioma,
:email,
:tema_id,
:encrypted_password,
:encrypted_password,
:fechacreacion_localizada,
:fechadeshabilitacion_localizada,
:reset_password_token,
Expand Down
10 changes: 8 additions & 2 deletions lib/sip/concerns/models/usuario.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ module Usuario
def email_required?
false
end
validates :email, format: { with: URI::MailTo::EMAIL_REGEXP }
validates_uniqueness_of :nusuario, :case_sensitive => false
validates_format_of :nusuario,
:with => /\A[a-zA-Z_0-9]+[-.a-zA-Z_0-9]*\z/
Expand Down Expand Up @@ -79,8 +80,13 @@ def fechadeshabilitacion_posible?
end
end

validates_presence_of :encrypted_password, :on=>:create
validates_confirmation_of :encrypted_password, :on=>:create
validates_presence_of :password, :on=>:create
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No me parece que cambie encrypted_password por password

validate :complejidad_clave
def complejidad_clave
return if password.blank? || password =~ /^(?=.*?[A-Z])(?=.*?[a-z])(?=.*?[0-9])(?=.*?[#?!@$%^&*-]).{8,70}$/

errors.add :password, 'Tu clave debe incluir por lo menos 1 letra mayúscula, 1 letra minúscula, 1 número y 1 caracter especial'
end

def confirmation_token=(value)
if value == ''
Expand Down