user_impersonate2 0.9.2 → 0.10.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +77 -19
- data/app/controllers/user_impersonate/impersonate_controller.rb +15 -8
- data/app/helpers/user_impersonate/application_helper.rb +4 -4
- data/lib/generators/user_impersonate/templates/config/initializers/user_impersonate.rb +38 -9
- data/lib/user_impersonate/devise_helpers.rb +2 -2
- data/lib/user_impersonate/version.rb +1 -1
- data/test/dummy-rails3/config/initializers/user_impersonate.rb +38 -11
- data/test/dummy-rails3/log/development.log +170 -0
- data/test/dummy-rails3/log/test.log +2090 -0
- data/test/dummy-rails4/config/initializers/user_impersonate.rb +38 -11
- data/test/dummy-rails4/log/development.log +18 -0
- data/test/dummy-rails4/log/test.log +1588 -0
- data/test/dummy-rails4/tmp/cache/assets/test/sprockets/291faed72d20664326ce265eb8e1ed2f +0 -0
- data/test/dummy-rails4/tmp/cache/assets/test/sprockets/2f5173deea6c795b8fdde723bb4b63af +0 -0
- data/test/dummy-rails4/tmp/cache/assets/test/sprockets/79203f7770f5d8956dee4606e93f3d65 +0 -0
- data/test/dummy-rails4/tmp/cache/assets/test/sprockets/8473d4c341d1accbf02a0c2d8270c68e +0 -0
- data/test/dummy-rails4/tmp/cache/assets/test/sprockets/a51c3d05425a76a50181d8144764ac8f +0 -0
- data/test/functional/impersonate_controller_test.rb +46 -0
- data/test/test_helper.rb +1 -0
- metadata +10 -6
- data/test/dummy-rails3/config/initializers/inflections.rb +0 -15
- data/test/dummy-rails4/config/initializers/inflections.rb +0 -15
@@ -1,18 +1,45 @@
|
|
1
1
|
module UserImpersonate
|
2
2
|
class Engine < Rails::Engine
|
3
|
-
|
4
|
-
config.
|
5
|
-
config.user_id_column = "id" # Such that User.find(aUser.id) works
|
6
|
-
config.user_name_column = "name" # Such that User.where("#{user_name_column} like ?", "%#{params[:search]}%") works
|
7
|
-
config.user_is_staff_method = "staff?" # current_user.staff?
|
3
|
+
# Devise user model
|
4
|
+
config.user_class = 'User'
|
8
5
|
|
9
|
-
|
6
|
+
# User model lookup method
|
7
|
+
config.user_finder = 'find'
|
10
8
|
|
11
|
-
#
|
12
|
-
|
13
|
-
config.redirect_on_revert = "/"
|
9
|
+
# User model primary key attribute
|
10
|
+
config.user_id_column = 'id'
|
14
11
|
|
15
|
-
|
16
|
-
|
12
|
+
# User model name attribute used for search
|
13
|
+
# Usage: User.where('#{user_name_column} like ?', '%#{params[:search]}%')
|
14
|
+
config.user_name_column = 'name'
|
15
|
+
|
16
|
+
# User model staff attribute
|
17
|
+
config.user_is_staff_method = 'staff?'
|
18
|
+
|
19
|
+
# Redirect to this path when entering impersonate mode
|
20
|
+
config.redirect_on_impersonate = '/'
|
21
|
+
|
22
|
+
# Redirect to this path when leaving impersonate mode
|
23
|
+
# In test mode, we use '/' since this includes an impersonation header
|
24
|
+
config.redirect_on_revert = '/'
|
25
|
+
|
26
|
+
# Devise filter method used to protect impersonation controller
|
27
|
+
# For Active Admin "AdminUser" model, change to 'authenticate_admin_user!'
|
28
|
+
config.authenticate_user_method = 'authenticate_user!'
|
29
|
+
|
30
|
+
# Devise method used to sign user in
|
31
|
+
config.sign_in_user_method = 'sign_in'
|
32
|
+
|
33
|
+
# Devise staff user class
|
34
|
+
# For Active Admin "AdminUser" model, change to 'AdminUser'
|
35
|
+
config.staff_class = 'User'
|
36
|
+
|
37
|
+
# Staff user model lookup method
|
38
|
+
config.staff_finder = 'find'
|
39
|
+
|
40
|
+
# Devise method storing current user
|
41
|
+
# For Active Admin "AdminUser" model, change to 'current_admin_user'
|
42
|
+
config.current_staff = 'current_user'
|
17
43
|
end
|
18
44
|
end
|
45
|
+
|
@@ -25,3 +25,21 @@
|
|
25
25
|
[1m[36m (20.0ms)[0m [1mINSERT INTO "schema_migrations" (version) VALUES ('20120914184123')[0m
|
26
26
|
[1m[35m (25.0ms)[0m INSERT INTO "schema_migrations" (version) VALUES ('20120914174453')
|
27
27
|
[1m[36mActiveRecord::SchemaMigration Load (0.1ms)[0m [1mSELECT "schema_migrations".* FROM "schema_migrations"[0m
|
28
|
+
[1m[36m (40.3ms)[0m [1mCREATE TABLE "users" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(255) DEFAULT '' NOT NULL, "email" varchar(255) DEFAULT '' NOT NULL, "encrypted_password" varchar(255) DEFAULT '' NOT NULL, "reset_password_token" varchar(255), "reset_password_sent_at" datetime, "remember_created_at" datetime, "sign_in_count" integer DEFAULT 0, "current_sign_in_at" datetime, "last_sign_in_at" datetime, "current_sign_in_ip" varchar(255), "last_sign_in_ip" varchar(255), "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL, "staff" boolean DEFAULT 'f') [0m
|
29
|
+
[1m[35m (40.7ms)[0m CREATE UNIQUE INDEX "index_users_on_email" ON "users" ("email")
|
30
|
+
[1m[36m (21.7ms)[0m [1mCREATE UNIQUE INDEX "index_users_on_reset_password_token" ON "users" ("reset_password_token")[0m
|
31
|
+
[1m[35m (22.0ms)[0m CREATE TABLE "schema_migrations" ("version" varchar(255) NOT NULL)
|
32
|
+
[1m[36m (37.6ms)[0m [1mCREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")[0m
|
33
|
+
[1m[35m (0.3ms)[0m SELECT version FROM "schema_migrations"
|
34
|
+
[1m[36m (36.6ms)[0m [1mINSERT INTO "schema_migrations" (version) VALUES ('20120914184123')[0m
|
35
|
+
[1m[35m (25.3ms)[0m INSERT INTO "schema_migrations" (version) VALUES ('20120914174453')
|
36
|
+
[1m[36mActiveRecord::SchemaMigration Load (0.3ms)[0m [1mSELECT "schema_migrations".* FROM "schema_migrations"[0m
|
37
|
+
[1m[36m (18.6ms)[0m [1mCREATE TABLE "users" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(255) DEFAULT '' NOT NULL, "email" varchar(255) DEFAULT '' NOT NULL, "encrypted_password" varchar(255) DEFAULT '' NOT NULL, "reset_password_token" varchar(255), "reset_password_sent_at" datetime, "remember_created_at" datetime, "sign_in_count" integer DEFAULT 0, "current_sign_in_at" datetime, "last_sign_in_at" datetime, "current_sign_in_ip" varchar(255), "last_sign_in_ip" varchar(255), "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL, "staff" boolean DEFAULT 'f') [0m
|
38
|
+
[1m[35m (33.8ms)[0m CREATE UNIQUE INDEX "index_users_on_email" ON "users" ("email")
|
39
|
+
[1m[36m (32.6ms)[0m [1mCREATE UNIQUE INDEX "index_users_on_reset_password_token" ON "users" ("reset_password_token")[0m
|
40
|
+
[1m[35m (20.8ms)[0m CREATE TABLE "schema_migrations" ("version" varchar(255) NOT NULL)
|
41
|
+
[1m[36m (16.3ms)[0m [1mCREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")[0m
|
42
|
+
[1m[35m (0.1ms)[0m SELECT version FROM "schema_migrations"
|
43
|
+
[1m[36m (15.9ms)[0m [1mINSERT INTO "schema_migrations" (version) VALUES ('20120914184123')[0m
|
44
|
+
[1m[35m (15.9ms)[0m INSERT INTO "schema_migrations" (version) VALUES ('20120914174453')
|
45
|
+
[1m[36mActiveRecord::SchemaMigration Load (0.1ms)[0m [1mSELECT "schema_migrations".* FROM "schema_migrations"[0m
|