switch_user 0.7.0 → 0.8.0

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore CHANGED
@@ -2,3 +2,4 @@ pkg/*
2
2
  *.gem
3
3
  .bundle
4
4
  .rvmrc
5
+ Gemfile.lock
data/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  switch_user
2
2
  ===========
3
3
 
4
- Inspired from [hobo][0], switch_user provides a convenient way to switch current user that speeds up your development.
4
+ Inspired from [hobo][0], switch_user provides a convenient way to switch current user that speeds up your development and reproduce user specified error on production.
5
5
 
6
6
  Use Case
7
7
  --------
@@ -10,7 +10,7 @@ switch_user is very useful in such use cases
10
10
 
11
11
  1. switch current users in development so that you don't waste your time to logout, login and input email (login) or password any more.
12
12
 
13
- 2. reproduce the user specified error in production. Sometimes the error is only raised for specified user, which is difficult to reproduce for developers, switch_user can help you reproduce it by login as that user.
13
+ 2. reproduce the user specified error on production. Sometimes the error is only raised for specified user, which is difficult to reproduce for developers, switch_user can help you reproduce it by login as that user.
14
14
 
15
15
  Example
16
16
  -------
@@ -37,7 +37,7 @@ or haml
37
37
 
38
38
  = switch_user_select
39
39
 
40
- If there are too many users (in production), the switch_user_select is not a good choice, you should call the switch user request by yourself.
40
+ If there are too many users (on production), the switch_user_select is not a good choice, you should call the switch user request by yourself.
41
41
 
42
42
  <%= link_to user.login, "/switch_user?scope_identifier=user_#{user.id}" %>
43
43
  <%= link_to admin.login, "/switch_user?scope_identifier=admin_#{admin.id}" %>
@@ -56,7 +56,7 @@ Configuration
56
56
  By default, you can switch between Guest and all users in users table, you don't need to do anything. The following is the default configuration.
57
57
 
58
58
  SwitchUser.setup do |config|
59
- # provider may be :devise, :authlogic or :restful_authentication
59
+ # provider may be :devise, :authlogic, :restful_authentication or :sorcery
60
60
  config.provider = :devise
61
61
 
62
62
  # available_users is a hash,
@@ -72,6 +72,21 @@ class SwitchUserController < ApplicationController
72
72
  end
73
73
  end
74
74
 
75
+ def sorcery_handle(params)
76
+ if params[:scope_identifier].blank?
77
+ self.logout
78
+ else
79
+ params[:scope_identifier] =~ /^([^_]+)_(.*)$/
80
+ scope, identifier = $1, $2
81
+
82
+ SwitchUser.available_users.keys.each do |s|
83
+ if scope == s.to_s && user = find_user(scope, s, identifier)
84
+ self.auto_login(user)
85
+ end
86
+ end
87
+ end
88
+ end
89
+
75
90
  def find_user(scope, identifier_scope, identifier)
76
91
  identifier_column = SwitchUser.available_users_identifiers[identifier_scope] || :id
77
92
  if identifier_column == :id
@@ -92,4 +107,8 @@ class SwitchUserController < ApplicationController
92
107
  def restful_authentication_current_user
93
108
  current_user
94
109
  end
110
+
111
+ def sorcery_current_user
112
+ current_user
113
+ end
95
114
  end
@@ -1,3 +1,3 @@
1
1
  module SwitchUser
2
- VERSION = "0.7.0"
2
+ VERSION = "0.8.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: switch_user
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.0
4
+ version: 0.8.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-03-25 00:00:00.000000000 Z
12
+ date: 2012-09-20 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
16
- requirement: &70197516282760 !ruby/object:Gem::Requirement
16
+ requirement: &70238901261280 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,7 +21,7 @@ dependencies:
21
21
  version: 1.0.0
22
22
  type: :development
23
23
  prerelease: false
24
- version_requirements: *70197516282760
24
+ version_requirements: *70238901261280
25
25
  description: Easily switch current user to speed up development
26
26
  email:
27
27
  - flyerhzm@gmail.com
@@ -31,7 +31,6 @@ extra_rdoc_files: []
31
31
  files:
32
32
  - .gitignore
33
33
  - Gemfile
34
- - Gemfile.lock
35
34
  - LICENSE
36
35
  - README.md
37
36
  - Rakefile
data/Gemfile.lock DELETED
@@ -1,15 +0,0 @@
1
- PATH
2
- remote: .
3
- specs:
4
- switch_user (0.5.1)
5
-
6
- GEM
7
- remote: http://rubygems.org/
8
- specs:
9
-
10
- PLATFORMS
11
- ruby
12
-
13
- DEPENDENCIES
14
- bundler (>= 1.0.0)
15
- switch_user!