Sudo Mode helps you easily require a password confirmation before any controller action of your choice.
This is inspired (heavily) by Github's implementation.
Add sudo_mode
to your Gemfile:
gem "sudo_mode"
And install:
$ bundle install
Foo::Application.routes.draw do
mount SudoMode::Engine => '/sudo' # You can replace '/sudo' with any other prefix
# ...
end
class FooController
require_password_confirmation_for :destroy
def destroy
# Bad things happen here
end
end
Override these keys in your locale files:
sudo_mode:
confirmation:
new:
confirmation_heading: "Confirm your Password"
check_password_button: "Check"
warning_message: "Are you sure you want to delete this?"
- Requires
has_secure_password
- Requires
ApplicationController
to have acurrent_user
method - Styling for the confirmation page is not taken care of
- All helper method calls in
application.html.erb
(and the partials it renders) must be explicitly called onmain_app
This gem was extracted from work on ashoka-survey-web.