-
-
Notifications
You must be signed in to change notification settings - Fork 121
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Locking Admin users after consecutive failed attempts is a good practice to prevent Brute Force password detection. This adds the necessary backbone (controller, routes and email template) so that using the lockable strategy with the extension requires minimal work over it.
- Loading branch information
1 parent
8d21a46
commit a0d7c46
Showing
6 changed files
with
46 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
lib/controllers/backend/spree/admin/user_unlocks_controller.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# frozen_string_literal: true | ||
|
||
module Spree | ||
module Admin | ||
class UserUnlocksController < Devise::UnlocksController | ||
helper 'spree/base' | ||
|
||
include Spree::Core::ControllerHelpers::Auth | ||
include Spree::Core::ControllerHelpers::Common | ||
include Spree::Core::ControllerHelpers::Store | ||
|
||
helper 'spree/admin/navigation' | ||
layout 'spree/layouts/admin' | ||
|
||
private | ||
|
||
def after_unlock_path_for(_resource) | ||
admin_login_path if is_navigational_format? | ||
end | ||
end | ||
end | ||
end |
7 changes: 7 additions & 0 deletions
7
lib/views/backend/spree/user_mailer/unlock_instructions.html.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<p>Hello <%= @user.email %>!</p> | ||
|
||
<p>Your account has been locked due to an excessive number of unsuccessful sign in attempts.</p> | ||
|
||
<p>Click the link below to unlock your account:</p> | ||
|
||
<p><%= link_to 'Unlock my account', @unlock_url %></p> |