devise-tokens 1.0.3 → 1.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/LICENSE +13 -0
- data/README.md +99 -0
- data/Rakefile +42 -0
- data/app/controllers/{devise_tokens → devise_token_auth}/application_controller.rb +8 -6
- data/app/controllers/{devise_tokens → devise_token_auth}/concerns/resource_finder.rb +4 -2
- data/app/controllers/{devise_tokens → devise_token_auth}/concerns/set_user_by_token.rb +24 -23
- data/app/controllers/{devise_tokens → devise_token_auth}/confirmations_controller.rb +9 -7
- data/app/controllers/{devise_tokens → devise_token_auth}/omniauth_callbacks_controller.rb +11 -9
- data/app/controllers/{devise_tokens → devise_token_auth}/passwords_controller.rb +16 -14
- data/app/controllers/{devise_tokens → devise_token_auth}/registrations_controller.rb +13 -11
- data/app/controllers/{devise_tokens → devise_token_auth}/sessions_controller.rb +9 -6
- data/app/controllers/{devise_tokens → devise_token_auth}/token_validations_controller.rb +5 -3
- data/app/controllers/{devise_tokens → devise_token_auth}/unlocks_controller.rb +7 -5
- data/app/models/{devise_tokens → devise_token_auth}/concerns/active_record_support.rb +2 -2
- data/app/models/{devise_tokens → devise_token_auth}/concerns/mongoid_support.rb +1 -1
- data/app/models/{devise_tokens → devise_token_auth}/concerns/tokens_serialization.rb +1 -1
- data/app/models/{devise_tokens → devise_token_auth}/concerns/user.rb +21 -17
- data/app/models/{devise_tokens → devise_token_auth}/concerns/user_omniauth_callbacks.rb +3 -3
- data/app/validators/devise_token_auth_email_validator.rb +2 -2
- data/config/locales/da-DK.yml +1 -1
- data/config/locales/de.yml +1 -1
- data/config/locales/en.yml +1 -1
- data/config/locales/es.yml +1 -1
- data/config/locales/fr.yml +1 -1
- data/config/locales/he.yml +1 -1
- data/config/locales/it.yml +1 -1
- data/config/locales/ja.yml +1 -1
- data/config/locales/nl.yml +1 -1
- data/config/locales/pl.yml +1 -1
- data/config/locales/pt-BR.yml +1 -1
- data/config/locales/pt.yml +1 -1
- data/config/locales/ro.yml +1 -1
- data/config/locales/ru.yml +1 -1
- data/config/locales/sq.yml +1 -1
- data/config/locales/sv.yml +1 -1
- data/config/locales/uk.yml +1 -1
- data/config/locales/vi.yml +1 -1
- data/config/locales/zh-CN.yml +1 -1
- data/config/locales/zh-HK.yml +1 -1
- data/config/locales/zh-TW.yml +1 -1
- data/lib/devise_token_auth.rb +14 -0
- data/lib/{devise_tokens → devise_token_auth}/blacklist.rb +0 -0
- data/lib/{devise_tokens → devise_token_auth}/controllers/helpers.rb +3 -3
- data/lib/{devise_tokens → devise_token_auth}/controllers/url_helpers.rb +2 -2
- data/lib/{devise_tokens → devise_token_auth}/engine.rb +7 -5
- data/lib/{devise_tokens → devise_token_auth}/errors.rb +3 -1
- data/lib/{devise_tokens → devise_token_auth}/rails/routes.rb +15 -15
- data/lib/{devise_tokens → devise_token_auth}/token_factory.rb +19 -19
- data/lib/{devise_tokens → devise_token_auth}/url.rb +4 -2
- data/lib/devise_token_auth/version.rb +5 -0
- data/lib/generators/{devise_tokens → devise_token_auth}/USAGE +9 -9
- data/lib/generators/{devise_tokens → devise_token_auth}/install_generator.rb +9 -9
- data/lib/generators/{devise_tokens → devise_token_auth}/install_generator_helpers.rb +9 -9
- data/lib/generators/{devise_tokens → devise_token_auth}/install_mongoid_generator.rb +5 -5
- data/lib/generators/{devise_tokens → devise_token_auth}/install_views_generator.rb +2 -2
- data/lib/generators/{devise_tokens/templates/devise_tokens.rb → devise_token_auth/templates/devise_token_auth.rb} +2 -2
- data/lib/generators/{devise_tokens/templates/devise_tokens_create_users.rb.erb → devise_token_auth/templates/devise_token_auth_create_users.rb.erb} +1 -1
- data/lib/generators/{devise_tokens → devise_token_auth}/templates/user.rb.erb +2 -2
- data/lib/generators/{devise_tokens → devise_token_auth}/templates/user_mongoid.rb.erb +2 -2
- data/lib/tasks/{devise_tokens_tasks.rake → devise_token_auth_tasks.rake} +2 -2
- data/test/controllers/custom/custom_confirmations_controller_test.rb +25 -0
- data/test/controllers/custom/custom_omniauth_callbacks_controller_test.rb +33 -0
- data/test/controllers/custom/custom_passwords_controller_test.rb +79 -0
- data/test/controllers/custom/custom_registrations_controller_test.rb +63 -0
- data/test/controllers/custom/custom_sessions_controller_test.rb +39 -0
- data/test/controllers/custom/custom_token_validations_controller_test.rb +42 -0
- data/test/controllers/demo_group_controller_test.rb +151 -0
- data/test/controllers/demo_mang_controller_test.rb +284 -0
- data/test/controllers/demo_user_controller_test.rb +629 -0
- data/test/controllers/devise_token_auth/confirmations_controller_test.rb +187 -0
- data/test/controllers/devise_token_auth/omniauth_callbacks_controller_test.rb +441 -0
- data/test/controllers/devise_token_auth/passwords_controller_test.rb +780 -0
- data/test/controllers/devise_token_auth/registrations_controller_test.rb +907 -0
- data/test/controllers/devise_token_auth/sessions_controller_test.rb +503 -0
- data/test/controllers/devise_token_auth/token_validations_controller_test.rb +102 -0
- data/test/controllers/devise_token_auth/unlocks_controller_test.rb +196 -0
- data/test/controllers/overrides/confirmations_controller_test.rb +47 -0
- data/test/controllers/overrides/omniauth_callbacks_controller_test.rb +53 -0
- data/test/controllers/overrides/passwords_controller_test.rb +64 -0
- data/test/controllers/overrides/registrations_controller_test.rb +46 -0
- data/test/controllers/overrides/sessions_controller_test.rb +35 -0
- data/test/controllers/overrides/token_validations_controller_test.rb +43 -0
- data/test/dummy/README.rdoc +28 -0
- data/test/dummy/app/active_record/lockable_user.rb +7 -0
- data/test/dummy/app/active_record/mang.rb +5 -0
- data/test/dummy/app/active_record/only_email_user.rb +7 -0
- data/test/dummy/app/active_record/scoped_user.rb +9 -0
- data/test/dummy/app/active_record/unconfirmable_user.rb +9 -0
- data/test/dummy/app/active_record/unregisterable_user.rb +9 -0
- data/test/dummy/app/active_record/user.rb +6 -0
- data/test/dummy/app/controllers/application_controller.rb +18 -0
- data/test/dummy/app/controllers/auth_origin_controller.rb +7 -0
- data/test/dummy/app/controllers/custom/confirmations_controller.rb +13 -0
- data/test/dummy/app/controllers/custom/omniauth_callbacks_controller.rb +13 -0
- data/test/dummy/app/controllers/custom/passwords_controller.rb +39 -0
- data/test/dummy/app/controllers/custom/registrations_controller.rb +39 -0
- data/test/dummy/app/controllers/custom/sessions_controller.rb +29 -0
- data/test/dummy/app/controllers/custom/token_validations_controller.rb +19 -0
- data/test/dummy/app/controllers/demo_group_controller.rb +15 -0
- data/test/dummy/app/controllers/demo_mang_controller.rb +14 -0
- data/test/dummy/app/controllers/demo_user_controller.rb +27 -0
- data/test/dummy/app/controllers/overrides/confirmations_controller.rb +28 -0
- data/test/dummy/app/controllers/overrides/omniauth_callbacks_controller.rb +16 -0
- data/test/dummy/app/controllers/overrides/passwords_controller.rb +35 -0
- data/test/dummy/app/controllers/overrides/registrations_controller.rb +29 -0
- data/test/dummy/app/controllers/overrides/sessions_controller.rb +36 -0
- data/test/dummy/app/controllers/overrides/token_validations_controller.rb +23 -0
- data/test/dummy/app/helpers/application_helper.rb +1058 -0
- data/test/dummy/app/models/concerns/favorite_color.rb +19 -0
- data/test/dummy/app/mongoid/lockable_user.rb +38 -0
- data/test/dummy/app/mongoid/mang.rb +46 -0
- data/test/dummy/app/mongoid/only_email_user.rb +33 -0
- data/test/dummy/app/mongoid/scoped_user.rb +50 -0
- data/test/dummy/app/mongoid/unconfirmable_user.rb +44 -0
- data/test/dummy/app/mongoid/unregisterable_user.rb +47 -0
- data/test/dummy/app/mongoid/user.rb +49 -0
- data/test/dummy/app/views/layouts/application.html.erb +14 -0
- data/test/dummy/config.ru +18 -0
- data/test/dummy/config/application.rb +48 -0
- data/test/dummy/config/application.yml.bk +0 -0
- data/test/dummy/config/boot.rb +11 -0
- data/test/dummy/config/environment.rb +7 -0
- data/test/dummy/config/environments/development.rb +46 -0
- data/test/dummy/config/environments/production.rb +84 -0
- data/test/dummy/config/environments/test.rb +50 -0
- data/test/dummy/config/initializers/assets.rb +10 -0
- data/test/dummy/config/initializers/backtrace_silencers.rb +9 -0
- data/test/dummy/config/initializers/cookies_serializer.rb +5 -0
- data/test/dummy/config/initializers/devise.rb +290 -0
- data/test/dummy/config/initializers/devise_token_auth.rb +55 -0
- data/test/dummy/config/initializers/figaro.rb +3 -0
- data/test/dummy/config/initializers/filter_parameter_logging.rb +6 -0
- data/test/dummy/config/initializers/inflections.rb +18 -0
- data/test/dummy/config/initializers/mime_types.rb +6 -0
- data/test/dummy/config/initializers/omniauth.rb +10 -0
- data/test/dummy/config/initializers/session_store.rb +5 -0
- data/test/dummy/config/initializers/wrap_parameters.rb +16 -0
- data/test/dummy/config/routes.rb +55 -0
- data/test/dummy/config/spring.rb +3 -0
- data/test/dummy/db/migrate/20140715061447_devise_token_auth_create_users.rb +58 -0
- data/test/dummy/db/migrate/20140715061805_devise_token_auth_create_mangs.rb +57 -0
- data/test/dummy/db/migrate/20140829044006_add_operating_thetan_to_user.rb +8 -0
- data/test/dummy/db/migrate/20140916224624_add_favorite_color_to_mangs.rb +7 -0
- data/test/dummy/db/migrate/20141222035835_devise_token_auth_create_only_email_users.rb +55 -0
- data/test/dummy/db/migrate/20141222053502_devise_token_auth_create_unregisterable_users.rb +56 -0
- data/test/dummy/db/migrate/20150708104536_devise_token_auth_create_unconfirmable_users.rb +56 -0
- data/test/dummy/db/migrate/20160103235141_devise_token_auth_create_scoped_users.rb +56 -0
- data/test/dummy/db/migrate/20160629184441_devise_token_auth_create_lockable_users.rb +56 -0
- data/test/dummy/db/schema.rb +173 -0
- data/test/dummy/lib/migration_database_helper.rb +43 -0
- data/test/factories/users.rb +40 -0
- data/test/lib/devise_token_auth/blacklist_test.rb +11 -0
- data/test/lib/devise_token_auth/token_factory_test.rb +191 -0
- data/test/lib/devise_token_auth/url_test.rb +26 -0
- data/test/lib/generators/devise_token_auth/install_generator_test.rb +217 -0
- data/test/lib/generators/devise_token_auth/install_generator_with_namespace_test.rb +222 -0
- data/test/lib/generators/devise_token_auth/install_views_generator_test.rb +25 -0
- data/test/models/concerns/mongoid_support_test.rb +31 -0
- data/test/models/concerns/tokens_serialization_test.rb +70 -0
- data/test/models/only_email_user_test.rb +29 -0
- data/test/models/user_test.rb +108 -0
- data/test/support/controllers/routes.rb +43 -0
- data/test/test_helper.rb +103 -0
- metadata +246 -37
- data/lib/devise_tokens.rb +0 -14
- data/lib/devise_tokens/version.rb +0 -3
@@ -0,0 +1,56 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
include MigrationDatabaseHelper
|
4
|
+
|
5
|
+
class DeviseTokenAuthCreateUnconfirmableUsers < ActiveRecord::Migration[4.2]
|
6
|
+
def change
|
7
|
+
create_table(:unconfirmable_users) do |t|
|
8
|
+
## Required
|
9
|
+
t.string :provider, null: false
|
10
|
+
t.string :uid, null: false, default: ''
|
11
|
+
|
12
|
+
## Database authenticatable
|
13
|
+
t.string :encrypted_password, null: false, default: ''
|
14
|
+
|
15
|
+
## Recoverable
|
16
|
+
t.string :reset_password_token
|
17
|
+
t.datetime :reset_password_sent_at
|
18
|
+
t.boolean :allow_password_change, default: false
|
19
|
+
|
20
|
+
## Rememberable
|
21
|
+
t.datetime :remember_created_at
|
22
|
+
|
23
|
+
## Confirmable
|
24
|
+
# t.string :confirmation_token
|
25
|
+
# t.datetime :confirmed_at
|
26
|
+
# t.datetime :confirmation_sent_at
|
27
|
+
# t.string :unconfirmed_email # Only if using reconfirmable
|
28
|
+
|
29
|
+
## Lockable
|
30
|
+
# t.integer :failed_attempts, :default => 0, :null => false # Only if lock strategy is :failed_attempts
|
31
|
+
# t.string :unlock_token # Only if unlock strategy is :email or :both
|
32
|
+
# t.datetime :locked_at
|
33
|
+
|
34
|
+
## User Info
|
35
|
+
t.string :name
|
36
|
+
t.string :nickname
|
37
|
+
t.string :image
|
38
|
+
t.string :email
|
39
|
+
|
40
|
+
## Tokens
|
41
|
+
if json_supported_database?
|
42
|
+
t.json :tokens
|
43
|
+
else
|
44
|
+
t.text :tokens
|
45
|
+
end
|
46
|
+
|
47
|
+
t.timestamps
|
48
|
+
end
|
49
|
+
|
50
|
+
add_index :unconfirmable_users, :email
|
51
|
+
add_index :unconfirmable_users, [:uid, :provider], unique: true
|
52
|
+
add_index :unconfirmable_users, :reset_password_token, unique: true
|
53
|
+
# add_index :nice_users, :confirmation_token, :unique => true
|
54
|
+
# add_index :nice_users, :unlock_token, :unique => true
|
55
|
+
end
|
56
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
include MigrationDatabaseHelper
|
4
|
+
|
5
|
+
class DeviseTokenAuthCreateScopedUsers < ActiveRecord::Migration[4.2]
|
6
|
+
def change
|
7
|
+
create_table(:scoped_users) do |t|
|
8
|
+
## Required
|
9
|
+
t.string :provider, null: false
|
10
|
+
t.string :uid, null: false, default: ''
|
11
|
+
|
12
|
+
## Database authenticatable
|
13
|
+
t.string :encrypted_password, null: false, default: ''
|
14
|
+
|
15
|
+
## Recoverable
|
16
|
+
t.string :reset_password_token
|
17
|
+
t.datetime :reset_password_sent_at
|
18
|
+
t.boolean :allow_password_change, default: false
|
19
|
+
|
20
|
+
## Rememberable
|
21
|
+
t.datetime :remember_created_at
|
22
|
+
|
23
|
+
## Confirmable
|
24
|
+
t.string :confirmation_token
|
25
|
+
t.datetime :confirmed_at
|
26
|
+
t.datetime :confirmation_sent_at
|
27
|
+
t.string :unconfirmed_email # Only if using reconfirmable
|
28
|
+
|
29
|
+
## Lockable
|
30
|
+
# t.integer :failed_attempts, :default => 0, :null => false # Only if lock strategy is :failed_attempts
|
31
|
+
# t.string :unlock_token # Only if unlock strategy is :email or :both
|
32
|
+
# t.datetime :locked_at
|
33
|
+
|
34
|
+
## User Info
|
35
|
+
t.string :name
|
36
|
+
t.string :nickname
|
37
|
+
t.string :image
|
38
|
+
t.string :email
|
39
|
+
|
40
|
+
## Tokens
|
41
|
+
if json_supported_database?
|
42
|
+
t.json :tokens
|
43
|
+
else
|
44
|
+
t.text :tokens
|
45
|
+
end
|
46
|
+
|
47
|
+
t.timestamps
|
48
|
+
end
|
49
|
+
|
50
|
+
add_index :scoped_users, :email
|
51
|
+
add_index :scoped_users, [:uid, :provider], unique: true
|
52
|
+
add_index :scoped_users, :reset_password_token, unique: true
|
53
|
+
# add_index :scoped_users, :confirmation_token, :unique => true
|
54
|
+
# add_index :scoped_users, :unlock_token, :unique => true
|
55
|
+
end
|
56
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
include MigrationDatabaseHelper
|
4
|
+
|
5
|
+
class DeviseTokenAuthCreateLockableUsers < ActiveRecord::Migration[4.2]
|
6
|
+
def change
|
7
|
+
create_table(:lockable_users) do |t|
|
8
|
+
## Required
|
9
|
+
t.string :provider, null: false
|
10
|
+
t.string :uid, null: false, default: ''
|
11
|
+
|
12
|
+
## Database authenticatable
|
13
|
+
t.string :encrypted_password, null: false, default: ''
|
14
|
+
|
15
|
+
## Recoverable
|
16
|
+
# t.string :reset_password_token
|
17
|
+
# t.datetime :reset_password_sent_at
|
18
|
+
# t.boolean :allow_password_change, :default => false
|
19
|
+
|
20
|
+
## Rememberable
|
21
|
+
# t.datetime :remember_created_at
|
22
|
+
|
23
|
+
## Confirmable
|
24
|
+
# t.string :confirmation_token
|
25
|
+
# t.datetime :confirmed_at
|
26
|
+
# t.datetime :confirmation_sent_at
|
27
|
+
# t.string :unconfirmed_email # Only if using reconfirmable
|
28
|
+
|
29
|
+
## Lockable
|
30
|
+
t.integer :failed_attempts, default: 0, null: false # Only if lock strategy is :failed_attempts
|
31
|
+
t.string :unlock_token # Only if unlock strategy is :email or :both
|
32
|
+
t.datetime :locked_at
|
33
|
+
|
34
|
+
## User Info
|
35
|
+
t.string :name
|
36
|
+
t.string :nickname
|
37
|
+
t.string :image
|
38
|
+
t.string :email
|
39
|
+
|
40
|
+
## Tokens
|
41
|
+
if json_supported_database?
|
42
|
+
t.json :tokens
|
43
|
+
else
|
44
|
+
t.text :tokens
|
45
|
+
end
|
46
|
+
|
47
|
+
t.timestamps
|
48
|
+
end
|
49
|
+
|
50
|
+
add_index :lockable_users, :email
|
51
|
+
add_index :lockable_users, [:uid, :provider], unique: true
|
52
|
+
# add_index :lockable_users, :reset_password_token, :unique => true
|
53
|
+
# add_index :lockable_users, :confirmation_token, :unique => true
|
54
|
+
add_index :lockable_users, :unlock_token, unique: true
|
55
|
+
end
|
56
|
+
end
|
@@ -0,0 +1,173 @@
|
|
1
|
+
# This file is auto-generated from the current state of the database. Instead
|
2
|
+
# of editing this file, please use the migrations feature of Active Record to
|
3
|
+
# incrementally modify your database, and then regenerate this schema definition.
|
4
|
+
#
|
5
|
+
# Note that this schema.rb definition is the authoritative source for your
|
6
|
+
# database schema. If you need to create the application database on another
|
7
|
+
# system, you should be using db:schema:load, not running all the migrations
|
8
|
+
# from scratch. The latter is a flawed and unsustainable approach (the more migrations
|
9
|
+
# you'll amass, the slower it'll run and the greater likelihood for issues).
|
10
|
+
#
|
11
|
+
# It's strongly recommended that you check this file into your version control system.
|
12
|
+
|
13
|
+
ActiveRecord::Schema.define(version: 2016_06_29_184441) do
|
14
|
+
|
15
|
+
create_table "lockable_users", force: :cascade do |t|
|
16
|
+
t.string "provider", null: false
|
17
|
+
t.string "uid", default: "", null: false
|
18
|
+
t.string "encrypted_password", default: "", null: false
|
19
|
+
t.integer "failed_attempts", default: 0, null: false
|
20
|
+
t.string "unlock_token"
|
21
|
+
t.datetime "locked_at"
|
22
|
+
t.string "name"
|
23
|
+
t.string "nickname"
|
24
|
+
t.string "image"
|
25
|
+
t.string "email"
|
26
|
+
t.text "tokens"
|
27
|
+
t.datetime "created_at"
|
28
|
+
t.datetime "updated_at"
|
29
|
+
t.index ["email"], name: "index_lockable_users_on_email"
|
30
|
+
t.index ["uid", "provider"], name: "index_lockable_users_on_uid_and_provider", unique: true
|
31
|
+
t.index ["unlock_token"], name: "index_lockable_users_on_unlock_token", unique: true
|
32
|
+
end
|
33
|
+
|
34
|
+
create_table "mangs", force: :cascade do |t|
|
35
|
+
t.string "email"
|
36
|
+
t.string "encrypted_password", default: "", null: false
|
37
|
+
t.string "reset_password_token"
|
38
|
+
t.datetime "reset_password_sent_at"
|
39
|
+
t.string "reset_password_redirect_url"
|
40
|
+
t.boolean "allow_password_change", default: false
|
41
|
+
t.datetime "remember_created_at"
|
42
|
+
t.string "confirmation_token"
|
43
|
+
t.datetime "confirmed_at"
|
44
|
+
t.datetime "confirmation_sent_at"
|
45
|
+
t.string "unconfirmed_email"
|
46
|
+
t.string "name"
|
47
|
+
t.string "nickname"
|
48
|
+
t.string "image"
|
49
|
+
t.string "provider"
|
50
|
+
t.string "uid", default: "", null: false
|
51
|
+
t.text "tokens"
|
52
|
+
t.datetime "created_at"
|
53
|
+
t.datetime "updated_at"
|
54
|
+
t.string "favorite_color"
|
55
|
+
t.index ["confirmation_token"], name: "index_mangs_on_confirmation_token", unique: true
|
56
|
+
t.index ["email"], name: "index_mangs_on_email"
|
57
|
+
t.index ["reset_password_token"], name: "index_mangs_on_reset_password_token", unique: true
|
58
|
+
t.index ["uid", "provider"], name: "index_mangs_on_uid_and_provider", unique: true
|
59
|
+
end
|
60
|
+
|
61
|
+
create_table "only_email_users", force: :cascade do |t|
|
62
|
+
t.string "provider", null: false
|
63
|
+
t.string "uid", default: "", null: false
|
64
|
+
t.string "encrypted_password", default: "", null: false
|
65
|
+
t.string "name"
|
66
|
+
t.string "nickname"
|
67
|
+
t.string "image"
|
68
|
+
t.string "email"
|
69
|
+
t.text "tokens"
|
70
|
+
t.datetime "created_at"
|
71
|
+
t.datetime "updated_at"
|
72
|
+
t.index ["email"], name: "index_only_email_users_on_email"
|
73
|
+
t.index ["uid", "provider"], name: "index_only_email_users_on_uid_and_provider", unique: true
|
74
|
+
end
|
75
|
+
|
76
|
+
create_table "scoped_users", force: :cascade do |t|
|
77
|
+
t.string "provider", null: false
|
78
|
+
t.string "uid", default: "", null: false
|
79
|
+
t.string "encrypted_password", default: "", null: false
|
80
|
+
t.string "reset_password_token"
|
81
|
+
t.datetime "reset_password_sent_at"
|
82
|
+
t.boolean "allow_password_change", default: false
|
83
|
+
t.datetime "remember_created_at"
|
84
|
+
t.string "confirmation_token"
|
85
|
+
t.datetime "confirmed_at"
|
86
|
+
t.datetime "confirmation_sent_at"
|
87
|
+
t.string "unconfirmed_email"
|
88
|
+
t.string "name"
|
89
|
+
t.string "nickname"
|
90
|
+
t.string "image"
|
91
|
+
t.string "email"
|
92
|
+
t.text "tokens"
|
93
|
+
t.datetime "created_at"
|
94
|
+
t.datetime "updated_at"
|
95
|
+
t.index ["email"], name: "index_scoped_users_on_email"
|
96
|
+
t.index ["reset_password_token"], name: "index_scoped_users_on_reset_password_token", unique: true
|
97
|
+
t.index ["uid", "provider"], name: "index_scoped_users_on_uid_and_provider", unique: true
|
98
|
+
end
|
99
|
+
|
100
|
+
create_table "unconfirmable_users", force: :cascade do |t|
|
101
|
+
t.string "provider", null: false
|
102
|
+
t.string "uid", default: "", null: false
|
103
|
+
t.string "encrypted_password", default: "", null: false
|
104
|
+
t.string "reset_password_token"
|
105
|
+
t.datetime "reset_password_sent_at"
|
106
|
+
t.boolean "allow_password_change", default: false
|
107
|
+
t.datetime "remember_created_at"
|
108
|
+
t.string "name"
|
109
|
+
t.string "nickname"
|
110
|
+
t.string "image"
|
111
|
+
t.string "email"
|
112
|
+
t.text "tokens"
|
113
|
+
t.datetime "created_at"
|
114
|
+
t.datetime "updated_at"
|
115
|
+
t.index ["email"], name: "index_unconfirmable_users_on_email"
|
116
|
+
t.index ["reset_password_token"], name: "index_unconfirmable_users_on_reset_password_token", unique: true
|
117
|
+
t.index ["uid", "provider"], name: "index_unconfirmable_users_on_uid_and_provider", unique: true
|
118
|
+
end
|
119
|
+
|
120
|
+
create_table "unregisterable_users", force: :cascade do |t|
|
121
|
+
t.string "provider", null: false
|
122
|
+
t.string "uid", default: "", null: false
|
123
|
+
t.string "encrypted_password", default: "", null: false
|
124
|
+
t.string "reset_password_token"
|
125
|
+
t.datetime "reset_password_sent_at"
|
126
|
+
t.boolean "allow_password_change", default: false
|
127
|
+
t.datetime "remember_created_at"
|
128
|
+
t.string "confirmation_token"
|
129
|
+
t.datetime "confirmed_at"
|
130
|
+
t.datetime "confirmation_sent_at"
|
131
|
+
t.string "unconfirmed_email"
|
132
|
+
t.string "name"
|
133
|
+
t.string "nickname"
|
134
|
+
t.string "image"
|
135
|
+
t.string "email"
|
136
|
+
t.text "tokens"
|
137
|
+
t.datetime "created_at"
|
138
|
+
t.datetime "updated_at"
|
139
|
+
t.index ["email"], name: "index_unregisterable_users_on_email"
|
140
|
+
t.index ["reset_password_token"], name: "index_unregisterable_users_on_reset_password_token", unique: true
|
141
|
+
t.index ["uid", "provider"], name: "index_unregisterable_users_on_uid_and_provider", unique: true
|
142
|
+
end
|
143
|
+
|
144
|
+
create_table "users", force: :cascade do |t|
|
145
|
+
t.string "email"
|
146
|
+
t.string "encrypted_password", default: "", null: false
|
147
|
+
t.string "reset_password_token"
|
148
|
+
t.datetime "reset_password_sent_at"
|
149
|
+
t.string "reset_password_redirect_url"
|
150
|
+
t.boolean "allow_password_change", default: false
|
151
|
+
t.datetime "remember_created_at"
|
152
|
+
t.string "confirmation_token"
|
153
|
+
t.datetime "confirmed_at"
|
154
|
+
t.datetime "confirmation_sent_at"
|
155
|
+
t.string "unconfirmed_email"
|
156
|
+
t.string "name"
|
157
|
+
t.string "nickname"
|
158
|
+
t.string "image"
|
159
|
+
t.string "provider"
|
160
|
+
t.string "uid", default: "", null: false
|
161
|
+
t.text "tokens"
|
162
|
+
t.datetime "created_at"
|
163
|
+
t.datetime "updated_at"
|
164
|
+
t.integer "operating_thetan"
|
165
|
+
t.string "favorite_color"
|
166
|
+
t.index ["confirmation_token"], name: "index_users_on_confirmation_token", unique: true
|
167
|
+
t.index ["email"], name: "index_users_on_email"
|
168
|
+
t.index ["nickname"], name: "index_users_on_nickname", unique: true
|
169
|
+
t.index ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true
|
170
|
+
t.index ["uid", "provider"], name: "index_users_on_uid_and_provider", unique: true
|
171
|
+
end
|
172
|
+
|
173
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# polyfill Rails >= 5 versioned migrations
|
4
|
+
|
5
|
+
unless ActiveRecord::Migration.respond_to?(:[])
|
6
|
+
module ActiveRecord
|
7
|
+
class Migration
|
8
|
+
def self.[](_version)
|
9
|
+
self
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
module MigrationDatabaseHelper
|
16
|
+
def json_supported_database?
|
17
|
+
(postgres? && postgres_correct_version?) || (mysql? && mysql_correct_version?)
|
18
|
+
end
|
19
|
+
|
20
|
+
def postgres?
|
21
|
+
database_name == 'ActiveRecord::ConnectionAdapters::PostgreSQLAdapter'
|
22
|
+
end
|
23
|
+
|
24
|
+
def postgres_correct_version?
|
25
|
+
database_version > '9.3'
|
26
|
+
end
|
27
|
+
|
28
|
+
def mysql?
|
29
|
+
database_name == 'ActiveRecord::ConnectionAdapters::MysqlAdapter'
|
30
|
+
end
|
31
|
+
|
32
|
+
def mysql_correct_version?
|
33
|
+
database_version > '5.7.7'
|
34
|
+
end
|
35
|
+
|
36
|
+
def database_name
|
37
|
+
ActiveRecord::Base.connection.class.name
|
38
|
+
end
|
39
|
+
|
40
|
+
def database_version
|
41
|
+
ActiveRecord::Base.connection.select_value('SELECT VERSION()')
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
FactoryBot.define do
|
2
|
+
factory :user do
|
3
|
+
email { Faker::Internet.unique.safe_email }
|
4
|
+
password { Faker::Internet.password }
|
5
|
+
provider { 'email' }
|
6
|
+
|
7
|
+
transient do
|
8
|
+
allow_unconfirmed_period { Time.now.utc - Devise.allow_unconfirmed_access_for }
|
9
|
+
end
|
10
|
+
|
11
|
+
trait :with_nickname do
|
12
|
+
nickname { Faker::Internet.username }
|
13
|
+
end
|
14
|
+
|
15
|
+
trait :confirmed do
|
16
|
+
after(:create) { |user| user.confirm }
|
17
|
+
end
|
18
|
+
|
19
|
+
# confirmation period is expired
|
20
|
+
trait :unconfirmed do
|
21
|
+
after(:create) do |user, evaluator|
|
22
|
+
user.update_attribute(:confirmation_sent_at, evaluator.allow_unconfirmed_period - 1.day )
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
trait :facebook do
|
27
|
+
uid { Faker::Number.number }
|
28
|
+
provider { 'facebook' }
|
29
|
+
end
|
30
|
+
|
31
|
+
trait :locked do
|
32
|
+
after(:create) { |user| user.lock_access! }
|
33
|
+
end
|
34
|
+
|
35
|
+
factory :lockable_user, class: 'LockableUser'
|
36
|
+
factory :mang_user, class: 'Mang'
|
37
|
+
factory :only_email_user, class: 'OnlyEmailUser'
|
38
|
+
factory :scoped_user, class: 'ScopedUser'
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'test_helper'
|
4
|
+
|
5
|
+
class DeviseTokenAuth::BlacklistTest < ActiveSupport::TestCase
|
6
|
+
describe Devise::Models::Authenticatable::BLACKLIST_FOR_SERIALIZATION do
|
7
|
+
test 'should include :tokens' do
|
8
|
+
assert Devise::Models::Authenticatable::BLACKLIST_FOR_SERIALIZATION.include?(:tokens)
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
@@ -0,0 +1,191 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class DeviseTokenAuth::TokenFactoryTest < ActiveSupport::TestCase
|
4
|
+
describe 'TokenFactory module' do
|
5
|
+
let(:tf) { DeviseTokenAuth::TokenFactory }
|
6
|
+
let(:token_regexp) { /^[-_A-Za-z0-9]{22}$/ }
|
7
|
+
|
8
|
+
it 'should be defined' do
|
9
|
+
assert_equal(tf.present?, true)
|
10
|
+
assert_kind_of(Module, tf)
|
11
|
+
end
|
12
|
+
|
13
|
+
describe 'interface' do
|
14
|
+
let(:token_hash_cost_regexp) { /\$[\w]+\$([\d]+)\$/ }
|
15
|
+
let(:lifespan) { 10 }
|
16
|
+
let(:cost) { DeviseTokenAuth.token_cost }
|
17
|
+
|
18
|
+
it '::secure_string' do
|
19
|
+
assert_respond_to(tf, :secure_string)
|
20
|
+
|
21
|
+
secure_string = tf.secure_string
|
22
|
+
assert_equal(secure_string.size, 22)
|
23
|
+
assert_match(token_regexp, secure_string)
|
24
|
+
|
25
|
+
SecureRandom.stub(:urlsafe_base64, secure_string) do
|
26
|
+
assert_equal(tf.secure_string, secure_string)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
it '::client' do
|
31
|
+
assert_respond_to(tf, :client)
|
32
|
+
|
33
|
+
client = tf.client
|
34
|
+
assert_equal(client.size, 22)
|
35
|
+
assert_match(token_regexp, client)
|
36
|
+
|
37
|
+
secure_string = tf.secure_string
|
38
|
+
tf.stub(:secure_string, secure_string) do
|
39
|
+
assert_equal(tf.client, secure_string)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
it '::token' do
|
44
|
+
assert_respond_to(tf, :token)
|
45
|
+
|
46
|
+
token = tf.token
|
47
|
+
assert_kind_of(String, token)
|
48
|
+
assert_equal(token.size, 22)
|
49
|
+
assert_match(token_regexp, token)
|
50
|
+
|
51
|
+
secure_string = tf.secure_string
|
52
|
+
tf.stub(:secure_string, secure_string) do
|
53
|
+
assert_equal(tf.token, secure_string)
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
it '::token_hash(args)' do
|
58
|
+
assert_respond_to(tf, :token_hash)
|
59
|
+
|
60
|
+
token_hash = tf.token_hash(tf.token)
|
61
|
+
assert_equal(token_hash.size, 60)
|
62
|
+
assert_kind_of(String, token_hash)
|
63
|
+
|
64
|
+
token_cost = token_hash_cost_regexp.match(token_hash)[1].to_i
|
65
|
+
assert_equal(token_cost, cost)
|
66
|
+
|
67
|
+
cost = DeviseTokenAuth.token_cost == 4 ? 10 : 4
|
68
|
+
token_hash = tf.token_hash(tf.token, cost)
|
69
|
+
token_cost = token_hash_cost_regexp.match(token_hash)[1].to_i
|
70
|
+
assert_equal(token_cost, cost)
|
71
|
+
|
72
|
+
cost = nil
|
73
|
+
token_hash = tf.token_hash(tf.token, cost)
|
74
|
+
token_cost = token_hash_cost_regexp.match(token_hash)[1].to_i
|
75
|
+
assert_equal(token_cost, DeviseTokenAuth.token_cost)
|
76
|
+
end
|
77
|
+
|
78
|
+
it '::expiry' do
|
79
|
+
assert_respond_to(tf, :expiry)
|
80
|
+
|
81
|
+
assert_kind_of(Integer, tf.expiry)
|
82
|
+
assert tf.expiry > Time.now.to_i
|
83
|
+
end
|
84
|
+
|
85
|
+
it '::expiry(args)' do
|
86
|
+
time = Time.now
|
87
|
+
Time.stub(:now, time) do
|
88
|
+
assert_equal(tf.expiry(lifespan), (time + lifespan).to_i)
|
89
|
+
|
90
|
+
lifespan = nil
|
91
|
+
assert_equal(tf.expiry(lifespan), (time + DeviseTokenAuth.token_lifespan).to_i)
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
it '::create' do
|
96
|
+
assert_respond_to(tf, :create)
|
97
|
+
|
98
|
+
token = tf.create
|
99
|
+
assert token
|
100
|
+
token.members.each { |m| refute_nil token[m] }
|
101
|
+
end
|
102
|
+
|
103
|
+
it '::create(args)' do
|
104
|
+
client = tf.client
|
105
|
+
token = tf.create(client: client)
|
106
|
+
assert_equal(token.client, client)
|
107
|
+
|
108
|
+
time = Time.now
|
109
|
+
Time.stub(:now, time) do
|
110
|
+
token = tf.create(lifespan: lifespan)
|
111
|
+
assert_equal(token.expiry, (time + lifespan).to_i)
|
112
|
+
end
|
113
|
+
|
114
|
+
token = tf.create(cost: cost)
|
115
|
+
token_cost = token_hash_cost_regexp.match(token.token_hash)[1].to_i
|
116
|
+
assert_equal(token_cost, cost)
|
117
|
+
end
|
118
|
+
|
119
|
+
it '::new' do
|
120
|
+
assert_respond_to(tf, :new)
|
121
|
+
|
122
|
+
token = tf.new
|
123
|
+
token.each { |v| assert_nil v }
|
124
|
+
end
|
125
|
+
|
126
|
+
it '::valid_token_hash?' do
|
127
|
+
assert_respond_to(tf, :valid_token_hash?)
|
128
|
+
|
129
|
+
refute tf.valid_token_hash?('koskoskos')
|
130
|
+
assert tf.valid_token_hash?(tf.create.token_hash)
|
131
|
+
end
|
132
|
+
|
133
|
+
it '::token_hash_is_token?' do
|
134
|
+
assert_respond_to(tf, :token_hash_is_token?)
|
135
|
+
|
136
|
+
token = tf.create
|
137
|
+
refute tf.token_hash_is_token?(token.token_hash, 'koskoskos')
|
138
|
+
refute tf.token_hash_is_token?('koskoskos', token.token)
|
139
|
+
assert tf.token_hash_is_token?(token.token_hash, token.token)
|
140
|
+
end
|
141
|
+
end
|
142
|
+
|
143
|
+
describe 'token object implements' do
|
144
|
+
let(:object) { tf.create }
|
145
|
+
|
146
|
+
it '#client' do
|
147
|
+
assert_respond_to(object, :client)
|
148
|
+
|
149
|
+
assert_kind_of(String, object.client)
|
150
|
+
assert_equal(object.client.size, 22)
|
151
|
+
assert_match(token_regexp, object.client)
|
152
|
+
end
|
153
|
+
|
154
|
+
it '#token' do
|
155
|
+
assert_respond_to(object, :token)
|
156
|
+
|
157
|
+
assert_kind_of(String, object.token)
|
158
|
+
assert_equal(object.token.size, 22)
|
159
|
+
assert_match(token_regexp, object.token)
|
160
|
+
end
|
161
|
+
|
162
|
+
it '#token_hash' do
|
163
|
+
assert_respond_to(object, :token_hash)
|
164
|
+
|
165
|
+
assert_kind_of(String, object.token_hash)
|
166
|
+
assert_equal(object.token_hash.size, 60)
|
167
|
+
end
|
168
|
+
|
169
|
+
it '#expiry' do
|
170
|
+
assert_respond_to(object, :expiry)
|
171
|
+
assert_kind_of(Integer, object.expiry)
|
172
|
+
end
|
173
|
+
|
174
|
+
it '#clear!' do
|
175
|
+
assert_respond_to(object, :clear!)
|
176
|
+
|
177
|
+
assert object.clear!
|
178
|
+
object.each { |v| assert_nil v }
|
179
|
+
end
|
180
|
+
|
181
|
+
it '#present?' do
|
182
|
+
assert_respond_to(object, :present?)
|
183
|
+
|
184
|
+
assert object.present?
|
185
|
+
|
186
|
+
object.token = nil
|
187
|
+
refute object.present?
|
188
|
+
end
|
189
|
+
end
|
190
|
+
end
|
191
|
+
end
|