devise_token_auth 0.1.30.beta3 → 0.1.30.beta4
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.
- checksums.yaml +4 -4
- data/README.md +16 -2
- data/app/controllers/devise_token_auth/concerns/set_user_by_token.rb +9 -9
- data/app/controllers/devise_token_auth/confirmations_controller.rb +5 -5
- data/app/controllers/devise_token_auth/omniauth_callbacks_controller.rb +10 -10
- data/app/controllers/devise_token_auth/passwords_controller.rb +34 -23
- data/app/controllers/devise_token_auth/registrations_controller.rb +10 -11
- data/app/controllers/devise_token_auth/sessions_controller.rb +23 -8
- data/app/controllers/devise_token_auth/token_validations_controller.rb +3 -3
- data/app/models/devise_token_auth/concerns/user.rb +1 -0
- data/app/views/devise_token_auth/omniauth_success.html.erb +1 -1
- data/lib/devise_token_auth/version.rb +1 -1
- data/lib/generators/devise_token_auth/templates/devise_token_auth_create_users.rb.erb +6 -6
- data/test/controllers/demo_group_controller_test.rb +14 -14
- data/test/controllers/demo_mang_controller_test.rb +25 -25
- data/test/controllers/demo_user_controller_test.rb +25 -25
- data/test/controllers/devise_token_auth/confirmations_controller_test.rb +6 -6
- data/test/controllers/devise_token_auth/omniauth_callbacks_controller_test.rb +11 -11
- data/test/controllers/devise_token_auth/passwords_controller_test.rb +110 -84
- data/test/controllers/devise_token_auth/registrations_controller_test.rb +23 -23
- data/test/controllers/devise_token_auth/sessions_controller_test.rb +68 -5
- data/test/controllers/overrides/omniauth_callbacks_controller_test.rb +3 -3
- data/test/controllers/overrides/passwords_controller_test.rb +4 -4
- data/test/controllers/overrides/sessions_controller_test.rb +1 -1
- data/test/controllers/overrides/token_validations_controller_test.rb +5 -5
- data/test/dummy/app/controllers/demo_mang_controller.rb +2 -2
- data/test/dummy/app/controllers/demo_user_controller.rb +2 -2
- data/test/dummy/app/controllers/overrides/confirmations_controller.rb +5 -5
- data/test/dummy/app/controllers/overrides/passwords_controller.rb +6 -6
- data/test/dummy/app/controllers/overrides/registrations_controller.rb +4 -4
- data/test/dummy/app/controllers/overrides/sessions_controller.rb +7 -7
- data/test/dummy/app/controllers/overrides/token_validations_controller.rb +3 -3
- data/test/dummy/config/application.yml +8 -0
- data/test/dummy/db/development.sqlite3 +0 -0
- data/test/dummy/db/migrate/20140715061447_devise_token_auth_create_users.rb +2 -2
- data/test/dummy/db/migrate/20140715061805_devise_token_auth_create_mangs.rb +2 -2
- data/test/dummy/db/migrate/20140928231203_devise_token_auth_create_evil_users.rb +2 -2
- data/test/dummy/db/schema.rb +12 -9
- data/test/dummy/db/test.sqlite3 +0 -0
- data/test/dummy/log/development.log +1979 -0
- data/test/dummy/log/test.log +183708 -0
- data/test/dummy/tmp/generators/app/views/devise/mailer/confirmation_instructions.html.erb +5 -0
- data/test/dummy/tmp/generators/app/views/devise/mailer/reset_password_instructions.html.erb +8 -0
- data/test/models/user_test.rb +37 -27
- metadata +10 -10
- data/test/dummy/tmp/generators/app/models/user.rb +0 -7
- data/test/dummy/tmp/generators/config/initializers/devise_token_auth.rb +0 -22
- data/test/dummy/tmp/generators/db/migrate/20141028214843_devise_token_auth_create_users.rb +0 -54
@@ -0,0 +1,5 @@
|
|
1
|
+
<p>Welcome <%= @email %>!</p>
|
2
|
+
|
3
|
+
<p>You can confirm your account email through the link below:</p>
|
4
|
+
|
5
|
+
<p><%= link_to 'Confirm my account', confirmation_url(@resource, confirmation_token: @token, config: message['client-config'].to_s, redirect_url: message['redirect-url']) %></p>
|
@@ -0,0 +1,8 @@
|
|
1
|
+
<p>Hello <%= @resource.email %>!</p>
|
2
|
+
|
3
|
+
<p>Someone has requested a link to change your password. You can do this through the link below.</p>
|
4
|
+
|
5
|
+
<p><%= link_to 'Change my password', edit_password_url(@resource, reset_password_token: @token, config: message['client-config'].to_s, redirect_url: message['redirect-url'].to_s) %></p>
|
6
|
+
|
7
|
+
<p>If you didn't request this, please ignore this email.</p>
|
8
|
+
<p>Your password won't change until you access the link above and create a new one.</p>
|
data/test/models/user_test.rb
CHANGED
@@ -6,74 +6,84 @@ class UserTest < ActiveSupport::TestCase
|
|
6
6
|
@password = Faker::Internet.password(10, 20)
|
7
7
|
@email = Faker::Internet.email
|
8
8
|
@success_url = Faker::Internet.url
|
9
|
-
@
|
9
|
+
@resource = User.new()
|
10
10
|
end
|
11
11
|
|
12
12
|
describe 'serialization' do
|
13
13
|
test 'hash should not include sensitive info' do
|
14
|
-
refute @
|
14
|
+
refute @resource.as_json[:tokens]
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
describe 'creation' do
|
19
|
+
test 'save fails if uid is missing' do
|
20
|
+
@resource.uid = nil
|
21
|
+
@resource.save
|
22
|
+
|
23
|
+
assert @resource.errors.messages[:uid]
|
15
24
|
end
|
16
25
|
end
|
17
26
|
|
18
27
|
describe 'email registration' do
|
19
28
|
test 'model should not save if email is blank' do
|
20
|
-
@
|
21
|
-
@
|
22
|
-
@
|
29
|
+
@resource.provider = 'email'
|
30
|
+
@resource.password = @password
|
31
|
+
@resource.password_confirmation = @password
|
23
32
|
|
24
|
-
refute @
|
25
|
-
assert @
|
33
|
+
refute @resource.save
|
34
|
+
assert @resource.errors.messages[:email]
|
26
35
|
end
|
27
36
|
end
|
28
37
|
|
29
38
|
describe 'oauth2 authentication' do
|
30
39
|
test 'model should save even if email is blank' do
|
31
|
-
@
|
32
|
-
@
|
33
|
-
@
|
40
|
+
@resource.provider = 'facebook'
|
41
|
+
@resource.uid = 123
|
42
|
+
@resource.password = @password
|
43
|
+
@resource.password_confirmation = @password
|
34
44
|
|
35
|
-
assert @
|
36
|
-
refute @
|
45
|
+
assert @resource.save
|
46
|
+
refute @resource.errors.messages[:email]
|
37
47
|
end
|
38
48
|
end
|
39
49
|
|
40
50
|
describe 'token expiry' do
|
41
51
|
before do
|
42
|
-
@
|
43
|
-
@
|
44
|
-
@
|
52
|
+
@resource = users(:confirmed_email_user)
|
53
|
+
@resource.skip_confirmation!
|
54
|
+
@resource.save!
|
45
55
|
|
46
|
-
@auth_headers = @
|
56
|
+
@auth_headers = @resource.create_new_auth_token
|
47
57
|
|
48
58
|
@token = @auth_headers['access-token']
|
49
59
|
@client_id = @auth_headers['client']
|
50
60
|
end
|
51
61
|
|
52
62
|
test 'should properly indicate whether token is current' do
|
53
|
-
assert @
|
63
|
+
assert @resource.token_is_current?(@token, @client_id)
|
54
64
|
# we want to update the expiry without forcing a cleanup (see below)
|
55
|
-
@
|
56
|
-
refute @
|
65
|
+
@resource.tokens[@client_id]['expiry'] = Time.now.to_i - 10.seconds
|
66
|
+
refute @resource.token_is_current?(@token, @client_id)
|
57
67
|
end
|
58
68
|
end
|
59
69
|
|
60
70
|
describe 'expired tokens are destroyed on save' do
|
61
71
|
before do
|
62
|
-
@
|
63
|
-
@
|
64
|
-
@
|
72
|
+
@resource = users(:confirmed_email_user)
|
73
|
+
@resource.skip_confirmation!
|
74
|
+
@resource.save!
|
65
75
|
|
66
|
-
@old_auth_headers = @
|
67
|
-
@new_auth_headers = @
|
68
|
-
expire_token(@
|
76
|
+
@old_auth_headers = @resource.create_new_auth_token
|
77
|
+
@new_auth_headers = @resource.create_new_auth_token
|
78
|
+
expire_token(@resource, @old_auth_headers['client'])
|
69
79
|
end
|
70
80
|
|
71
81
|
test 'expired token was removed' do
|
72
|
-
refute @
|
82
|
+
refute @resource.tokens[@old_auth_headers['client']]
|
73
83
|
end
|
74
84
|
|
75
85
|
test 'current token was not removed' do
|
76
|
-
assert @
|
86
|
+
assert @resource.tokens[@new_auth_headers['client']]
|
77
87
|
end
|
78
88
|
end
|
79
89
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: devise_token_auth
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.30.
|
4
|
+
version: 0.1.30.beta4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Lynn Hurley
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-11-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -30,14 +30,14 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '3.
|
33
|
+
version: '3.3'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '3.
|
40
|
+
version: '3.3'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: sqlite3
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -162,6 +162,7 @@ files:
|
|
162
162
|
- test/dummy/bin/spring
|
163
163
|
- test/dummy/config.ru
|
164
164
|
- test/dummy/config/application.rb
|
165
|
+
- test/dummy/config/application.yml
|
165
166
|
- test/dummy/config/application.yml.bk
|
166
167
|
- test/dummy/config/boot.rb
|
167
168
|
- test/dummy/config/database.yml
|
@@ -198,9 +199,8 @@ files:
|
|
198
199
|
- test/dummy/public/422.html
|
199
200
|
- test/dummy/public/500.html
|
200
201
|
- test/dummy/public/favicon.ico
|
201
|
-
- test/dummy/tmp/generators/app/
|
202
|
-
- test/dummy/tmp/generators/
|
203
|
-
- test/dummy/tmp/generators/db/migrate/20141028214843_devise_token_auth_create_users.rb
|
202
|
+
- test/dummy/tmp/generators/app/views/devise/mailer/confirmation_instructions.html.erb
|
203
|
+
- test/dummy/tmp/generators/app/views/devise/mailer/reset_password_instructions.html.erb
|
204
204
|
- test/dummy/tmp/restart.txt
|
205
205
|
- test/fixtures/evil_users.yml
|
206
206
|
- test/fixtures/mangs.yml
|
@@ -273,6 +273,7 @@ test_files:
|
|
273
273
|
- test/dummy/bin/rake
|
274
274
|
- test/dummy/bin/spring
|
275
275
|
- test/dummy/config/application.rb
|
276
|
+
- test/dummy/config/application.yml
|
276
277
|
- test/dummy/config/application.yml.bk
|
277
278
|
- test/dummy/config/boot.rb
|
278
279
|
- test/dummy/config/database.yml
|
@@ -312,9 +313,8 @@ test_files:
|
|
312
313
|
- test/dummy/public/favicon.ico
|
313
314
|
- test/dummy/Rakefile
|
314
315
|
- test/dummy/README.rdoc
|
315
|
-
- test/dummy/tmp/generators/app/
|
316
|
-
- test/dummy/tmp/generators/
|
317
|
-
- test/dummy/tmp/generators/db/migrate/20141028214843_devise_token_auth_create_users.rb
|
316
|
+
- test/dummy/tmp/generators/app/views/devise/mailer/confirmation_instructions.html.erb
|
317
|
+
- test/dummy/tmp/generators/app/views/devise/mailer/reset_password_instructions.html.erb
|
318
318
|
- test/dummy/tmp/restart.txt
|
319
319
|
- test/fixtures/evil_users.yml
|
320
320
|
- test/fixtures/mangs.yml
|
@@ -1,22 +0,0 @@
|
|
1
|
-
DeviseTokenAuth.setup do |config|
|
2
|
-
# By default the authorization headers will change after each request. The
|
3
|
-
# client is responsible for keeping track of the changing tokens. Change
|
4
|
-
# this to false to prevent the Authorization header from changing after
|
5
|
-
# each request.
|
6
|
-
#config.change_headers_on_each_request = true
|
7
|
-
|
8
|
-
# By default, users will need to re-authenticate after 2 weeks. This setting
|
9
|
-
# determines how long tokens will remain valid after they are issued.
|
10
|
-
#config.token_lifespan = 2.weeks
|
11
|
-
|
12
|
-
# Sometimes it's necessary to make several requests to the API at the same
|
13
|
-
# time. In this case, each request in the batch will need to share the same
|
14
|
-
# auth token. This setting determines how far apart the requests can be while
|
15
|
-
# still using the same auth token.
|
16
|
-
#config.batch_request_buffer_throttle = 5.seconds
|
17
|
-
|
18
|
-
# This route will be the prefix for all oauth2 redirect callbacks. For
|
19
|
-
# example, using the default '/omniauth', the github oauth2 provider will
|
20
|
-
# redirect successful authentications to '/omniauth/github/callback'
|
21
|
-
#config.omniauth_prefix = "/omniauth"
|
22
|
-
end
|
@@ -1,54 +0,0 @@
|
|
1
|
-
class DeviseTokenAuthCreateUsers < ActiveRecord::Migration
|
2
|
-
def change
|
3
|
-
create_table(:users) do |t|
|
4
|
-
## Database authenticatable
|
5
|
-
t.string :email
|
6
|
-
t.string :encrypted_password, :null => false, :default => ""
|
7
|
-
|
8
|
-
## Recoverable
|
9
|
-
t.string :reset_password_token
|
10
|
-
t.datetime :reset_password_sent_at
|
11
|
-
|
12
|
-
## Rememberable
|
13
|
-
t.datetime :remember_created_at
|
14
|
-
|
15
|
-
## Trackable
|
16
|
-
t.integer :sign_in_count, :default => 0, :null => false
|
17
|
-
t.datetime :current_sign_in_at
|
18
|
-
t.datetime :last_sign_in_at
|
19
|
-
t.string :current_sign_in_ip
|
20
|
-
t.string :last_sign_in_ip
|
21
|
-
|
22
|
-
## Confirmable
|
23
|
-
t.string :confirmation_token
|
24
|
-
t.datetime :confirmed_at
|
25
|
-
t.datetime :confirmation_sent_at
|
26
|
-
t.string :unconfirmed_email # Only if using reconfirmable
|
27
|
-
|
28
|
-
## Lockable
|
29
|
-
# t.integer :failed_attempts, :default => 0, :null => false # Only if lock strategy is :failed_attempts
|
30
|
-
# t.string :unlock_token # Only if unlock strategy is :email or :both
|
31
|
-
# t.datetime :locked_at
|
32
|
-
|
33
|
-
## User Info
|
34
|
-
t.string :name
|
35
|
-
t.string :nickname
|
36
|
-
t.string :image
|
37
|
-
|
38
|
-
## unique oauth id
|
39
|
-
t.string :provider
|
40
|
-
t.string :uid, :null => false, :default => ""
|
41
|
-
|
42
|
-
## Tokens
|
43
|
-
t.text :tokens
|
44
|
-
|
45
|
-
t.timestamps
|
46
|
-
end
|
47
|
-
|
48
|
-
add_index :users, :email
|
49
|
-
add_index :users, :uid, :unique => true
|
50
|
-
add_index :users, :reset_password_token, :unique => true
|
51
|
-
# add_index :users, :confirmation_token, :unique => true
|
52
|
-
# add_index :users, :unlock_token, :unique => true
|
53
|
-
end
|
54
|
-
end
|