recover superadmin password or reset otp

This commit is contained in:
Christophe Robillard 2020-11-04 20:06:48 +01:00
parent 8d23f6ae99
commit efd8ec85e8
5 changed files with 52 additions and 3 deletions

View file

@ -0,0 +1,6 @@
class Administrations::PasswordsController < Devise::PasswordsController
def update
super
self.resource.disable_otp!
end
end

View file

@ -0,0 +1,22 @@
- 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'
= f.password_field :password, autofocus: true, autocomplete: 'off'
= f.label 'Confirmez le nouveau mot de passe'
= f.password_field :password_confirmation, autocomplete: 'off'
= f.submit 'Changer le mot de passe', class: 'button primary'

View file

@ -0,0 +1,17 @@
- 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 'Réinitialiser', class: 'button primary'

View file

@ -15,4 +15,7 @@
= f.label :otp_attempt, 'Code OTP (uniquement si vous avez déjà activé 2FA)'
= f.text_field :otp_attempt
.auth-options
.text-right
= link_to "Mot de passe oublié ou réinitialisation 2FA ?", new_administration_password_path, class: "link"
= f.submit "Se connecter", class: "button large primary expand"

View file

@ -75,9 +75,10 @@ Rails.application.routes.draw do
# Authentication
#
devise_for :administrations,
skip: [:registrations],
controllers: { sessions: 'administrations/sessions' }
devise_for :administrations, skip: [:registrations], controllers: {
sessions: 'administrations/sessions',
passwords: 'administrations/passwords'
}
get 'administrations/edit_otp', to: 'administrations#edit_otp', as: 'edit_administration_otp'
put 'administrations/enable_otp', to: 'administrations#enable_otp', as: 'enable_administration_otp'