[Fix #1285] Create an endpoint to check password strength

This commit is contained in:
Mathieu Magnin 2018-09-26 09:01:33 +02:00 committed by gregoirenovel
parent 35da5d595f
commit 2507f963b1
2 changed files with 8 additions and 0 deletions

View file

@ -1,3 +1,5 @@
require 'zxcvbn'
class Administrateurs::ActivateController < ApplicationController
layout "new_application"
@ -29,6 +31,11 @@ class Administrateurs::ActivateController < ApplicationController
end
end
def test_password_strength
score = Zxcvbn.test(params[:password], [], ZXCVBN_DICTIONNARIES).score
render json: { score: score }
end
private
def update_administrateur_params

View file

@ -175,6 +175,7 @@ Rails.application.routes.draw do
namespace :admin do
get 'activate' => '/administrateurs/activate#new'
patch 'activate' => '/administrateurs/activate#create'
post 'activate/test_password_strength' => '/administrateurs/activate#test_password_strength'
get 'sign_in' => '/administrateurs/sessions#new'
get 'procedures/archived' => 'procedures#archived'
get 'procedures/draft' => 'procedures#draft'