devise_masquerade 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of devise_masquerade might be problematic. Click here for more details.
- data/README.md +10 -7
- data/app/controllers/devise/masquerades_controller.rb +4 -1
- data/lib/devise_masquerade/controllers/url_helpers.rb +4 -0
- data/lib/devise_masquerade/routes.rb +2 -3
- data/lib/devise_masquerade/version.rb +1 -1
- data/spec/controllers/devise/masquerades_controller_spec.rb +2 -2
- data/spec/dummy/config/environments/development.rb +0 -1
- metadata +1 -1
data/README.md
CHANGED
@@ -1,6 +1,11 @@
|
|
1
|
-
#
|
1
|
+
# Devise Masquerade
|
2
2
|
|
3
|
-
|
3
|
+
It's a utility library for enabling functionallity like login as button for
|
4
|
+
admin.
|
5
|
+
|
6
|
+
If you have multi users application and sometimes you want to test functionally
|
7
|
+
using login of existing user without requesting the password, define login as
|
8
|
+
button with url helper and use it.
|
4
9
|
|
5
10
|
## Installation
|
6
11
|
|
@@ -12,13 +17,11 @@ And then execute:
|
|
12
17
|
|
13
18
|
$ bundle
|
14
19
|
|
15
|
-
Or install it yourself as:
|
16
|
-
|
17
|
-
$ gem install devise_masquerade
|
18
|
-
|
19
20
|
## Usage
|
20
21
|
|
21
|
-
|
22
|
+
In the view you can use url helper for defining link:
|
23
|
+
|
24
|
+
= link_to "Login As", masquerade_path(user)
|
22
25
|
|
23
26
|
## Contributing
|
24
27
|
|
@@ -1,8 +1,11 @@
|
|
1
1
|
class Devise::MasqueradesController < DeviseController
|
2
2
|
prepend_before_filter :authenticate_scope!, :only => :masquerade
|
3
3
|
|
4
|
-
def
|
4
|
+
def show
|
5
5
|
self.resource = resource_class.to_adapter.find_first(:id => params[:id])
|
6
|
+
|
7
|
+
redirect_to(new_user_session_path) and return unless self.resource
|
8
|
+
|
6
9
|
self.resource.masquerade!
|
7
10
|
|
8
11
|
redirect_to(after_masquerade_path_for(self.resource))
|
@@ -1,13 +1,12 @@
|
|
1
1
|
module ActionDispatch::Routing
|
2
2
|
class Mapper
|
3
|
+
|
3
4
|
protected
|
4
5
|
|
5
6
|
def devise_masquerade(mapping, controllers)
|
6
|
-
|
7
|
+
resources :masquerade, :only => :show,
|
7
8
|
:path => mapping.path_names[:masquerade],
|
8
9
|
:controller => controllers[:masquerades] do
|
9
|
-
|
10
|
-
get :masquerade, :path => mapping.path_names[:accept], :as => :accept
|
11
10
|
end
|
12
11
|
end
|
13
12
|
end
|
@@ -13,7 +13,7 @@ describe Devise::MasqueradesController do
|
|
13
13
|
before do
|
14
14
|
SecureRandom.should_receive(:base64).and_return("secure_key")
|
15
15
|
|
16
|
-
get :
|
16
|
+
get :show, :id => user.to_param
|
17
17
|
end
|
18
18
|
|
19
19
|
it { should redirect_to("/?masquerade=secure_key") }
|
@@ -21,7 +21,7 @@ describe Devise::MasqueradesController do
|
|
21
21
|
end
|
22
22
|
|
23
23
|
context 'when not logged in' do
|
24
|
-
before { get :
|
24
|
+
before { get :show, :id => 'any_id' }
|
25
25
|
|
26
26
|
it { should redirect_to(new_user_session_path) }
|
27
27
|
end
|
@@ -11,7 +11,6 @@ Dummy::Application.configure do
|
|
11
11
|
|
12
12
|
# Show full error reports and disable caching
|
13
13
|
config.consider_all_requests_local = true
|
14
|
-
config.action_view.debug_rjs = true
|
15
14
|
config.action_controller.perform_caching = false
|
16
15
|
|
17
16
|
# Don't care if the mailer can't send
|