Enable Devise email unlock
This commit is contained in:
parent
9e5582f4d5
commit
38558a284f
4 changed files with 56 additions and 1 deletions
33
app/controllers/users/unlocks_controller.rb
Normal file
33
app/controllers/users/unlocks_controller.rb
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
class Users::UnlocksController < Devise::UnlocksController
|
||||||
|
skip_after_action :verify_authorized
|
||||||
|
skip_after_action :verify_policy_scoped
|
||||||
|
|
||||||
|
# GET /resource/unlock/new
|
||||||
|
# def new
|
||||||
|
# super
|
||||||
|
# end
|
||||||
|
|
||||||
|
# POST /resource/unlock
|
||||||
|
# def create
|
||||||
|
# super
|
||||||
|
# end
|
||||||
|
|
||||||
|
# GET /resource/unlock?unlock_token=abcdef
|
||||||
|
# def show
|
||||||
|
# super
|
||||||
|
# end
|
||||||
|
|
||||||
|
# protected
|
||||||
|
|
||||||
|
# The path used after sending unlock password instructions
|
||||||
|
# def after_sending_unlock_instructions_path_for(resource)
|
||||||
|
# super(resource)
|
||||||
|
# end
|
||||||
|
|
||||||
|
# The path used after unlocking the resource
|
||||||
|
# def after_unlock_path_for(resource)
|
||||||
|
# super(resource)
|
||||||
|
# end
|
||||||
|
end
|
21
app/views/users/unlocks/new.html.erb
Normal file
21
app/views/users/unlocks/new.html.erb
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
<div class="container">
|
||||||
|
<h2><%= translate '.resend_unlock_instructions' %></h2>
|
||||||
|
|
||||||
|
<%= simple_form_for resource, as: resource_name, url: unlock_path(resource_name) do |f| %>
|
||||||
|
<%= f.error_notification %>
|
||||||
|
<%= f.full_error :unlock_token %>
|
||||||
|
|
||||||
|
<div class="form-inputs">
|
||||||
|
<%= f.input :email,
|
||||||
|
required: true,
|
||||||
|
autofocus: true,
|
||||||
|
input_html: { autocomplete: 'email' } %>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-actions">
|
||||||
|
<%= f.button :submit, translate('.resend_unlock_instructions') %>
|
||||||
|
</div>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
|
<%= render 'users/shared/links' %>
|
||||||
|
</div>
|
|
@ -193,7 +193,7 @@ Devise.setup do |config|
|
||||||
# :time = Re-enables login after a certain amount of time (see :unlock_in below)
|
# :time = Re-enables login after a certain amount of time (see :unlock_in below)
|
||||||
# :both = Enables both strategies
|
# :both = Enables both strategies
|
||||||
# :none = No unlock strategy. You should handle unlocking by yourself.
|
# :none = No unlock strategy. You should handle unlocking by yourself.
|
||||||
config.unlock_strategy = :time
|
config.unlock_strategy = :both
|
||||||
|
|
||||||
# Number of authentication tries before locking an account if lock_strategy
|
# Number of authentication tries before locking an account if lock_strategy
|
||||||
# is failed attempts.
|
# is failed attempts.
|
||||||
|
|
|
@ -26,6 +26,7 @@ Rails.application.routes.draw do
|
||||||
registrations: 'users/registrations',
|
registrations: 'users/registrations',
|
||||||
confirmations: 'users/confirmations',
|
confirmations: 'users/confirmations',
|
||||||
passwords: 'users/passwords',
|
passwords: 'users/passwords',
|
||||||
|
unlocks: 'users/unlocks',
|
||||||
}
|
}
|
||||||
|
|
||||||
resources :membership_applications, only: %i[new create]
|
resources :membership_applications, only: %i[new create]
|
||||||
|
|
Reference in a new issue