demarches-normaliennes/app/controllers/password_complexity_controller.rb
2024-09-16 15:28:14 +02:00

17 lines
435 B
Ruby

# frozen_string_literal: true
class PasswordComplexityController < ApplicationController
def show
@score, @length = ZxcvbnService.new(password_param).complexity
@min_length = PASSWORD_MIN_LENGTH
@min_complexity = PASSWORD_COMPLEXITY_FOR_ADMIN
end
private
def password_param
params
.transform_keys! { |k| params[k].try(:has_key?, :password) ? 'resource' : k }
.dig(:resource, :password)
end
end