devise: unify password reset views
By default, Devise will look for views: 1. First in `views/resource/passwords/…`, 2. Then in `views/devise/passwords/…` if not found. By moving the views to `views/devise`, we avoid having a partial in `views/shared` that we need to include manually, and instead let Devise do the job automatically.
This commit is contained in:
parent
80f9d4adc0
commit
e5f449b595
7 changed files with 2 additions and 56 deletions
|
@ -1,14 +0,0 @@
|
|||
class Administrateurs::PasswordsController < ApplicationController
|
||||
def test_strength
|
||||
@score, @words, @length = ZxcvbnService.new(password_params[:password]).complexity
|
||||
@min_length = PASSWORD_MIN_LENGTH
|
||||
@min_complexity = PASSWORD_COMPLEXITY_FOR_ADMIN
|
||||
render 'shared/password/test_strength'
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def password_params
|
||||
params.require(:administrateur).permit(:password)
|
||||
end
|
||||
end
|
|
@ -1,6 +0,0 @@
|
|||
- content_for(:title, 'Changement de mot de passe')
|
||||
|
||||
- content_for :footer do
|
||||
= render partial: 'root/footer'
|
||||
|
||||
= render 'shared/password/edit', test_password_strength: administrateurs_password_test_strength_path
|
|
@ -1,19 +0,0 @@
|
|||
- content_for(:title, 'Changement de mot de passe')
|
||||
|
||||
- content_for :footer do
|
||||
= render partial: 'root/footer'
|
||||
|
||||
.container.devise-container
|
||||
.one-column-centered
|
||||
= devise_error_messages!
|
||||
|
||||
= form_for(resource, as: resource_name, url: password_path(resource_name), html: { method: :patch, class: 'form' }) do |f|
|
||||
|
||||
%h1 Changement de mot de passe
|
||||
|
||||
= f.hidden_field :reset_password_token
|
||||
|
||||
= f.label 'Nouveau mot de passe'
|
||||
= render 'password_complexity/field', { form: f, test_complexity: populated_resource.validate_password_complexity? }
|
||||
|
||||
= f.submit 'Changer le mot de passe', class: 'button large primary expand', id: "submit-password", data: { disable_with: "Envoi..." }
|
|
@ -1,17 +0,0 @@
|
|||
- content_for(:title, 'Mot de passe oublié')
|
||||
|
||||
- content_for :footer do
|
||||
= render partial: 'root/footer'
|
||||
|
||||
.container.devise-container
|
||||
.one-column-centered
|
||||
= devise_error_messages!
|
||||
|
||||
= form_for(resource, as: resource_name, url: password_path(resource_name), html: { class: 'form' }) do |f|
|
||||
|
||||
%h1 Mot de passe oublié
|
||||
|
||||
= f.label :email, 'Email'
|
||||
= f.email_field :email, autofocus: true
|
||||
|
||||
= f.submit 'Demander un nouveau mot de passe', class: 'button large expand primary'
|
|
@ -85,10 +85,12 @@ feature 'Managing password:' do
|
|||
expect(page).to have_content 'Changement de mot de passe'
|
||||
|
||||
fill_in 'super_admin_password', with: weak_password
|
||||
fill_in 'super_admin_password_confirmation', with: weak_password
|
||||
expect(page).to have_text('Mot de passe très vulnérable')
|
||||
expect(page).to have_button('Changer le mot de passe', disabled: true)
|
||||
|
||||
fill_in 'super_admin_password', with: strong_password
|
||||
fill_in 'super_admin_password_confirmation', with: strong_password
|
||||
expect(page).to have_text('Mot de passe suffisamment fort et sécurisé')
|
||||
expect(page).to have_button('Changer le mot de passe', disabled: false)
|
||||
|
||||
|
|
Loading…
Reference in a new issue