devise_multiple_token_auth 0.0.24 → 0.0.25
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/devise_multiple_token_auth.rb +1 -0
- data/lib/devise_multiple_token_auth/action_controller/api.rb +25 -0
- data/lib/devise_multiple_token_auth/action_controller/base.rb +2 -2
- data/lib/devise_multiple_token_auth/version.rb +1 -1
- metadata +6 -9
- data/test/dummy/db/development.sqlite3 +0 -0
- data/test/dummy/log/development.log +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 01ab46fb5479c4f0b97e00e9ff05aecf1b192e8a
|
4
|
+
data.tar.gz: 5bd999cbb46235d98d748b90534c819aefc83693
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: edbbd08936fe1e80f075518717b02036bba200c8f968a6199535ad072ec53d40bf91c67e270dbbf7ff0fb0d36ead056d0c0019cb00d275c17bee22a9afa57e77
|
7
|
+
data.tar.gz: 9abdf33d9c192a82c735763da6ba482f4cb1ad19fb57b8d2a0c4924754c25b367f889bb6cc46f14c30186d07a5eddb0a6b66d2d8c1589622746393f83d3dad61
|
@@ -2,6 +2,7 @@ require "devise_multiple_token_auth/engine"
|
|
2
2
|
require "devise_multiple_token_auth/active_record/base"
|
3
3
|
require "devise_multiple_token_auth/version"
|
4
4
|
require 'devise_multiple_token_auth/action_controller/base'
|
5
|
+
require 'devise_multiple_token_auth/action_controller/api'
|
5
6
|
module DeviseMultipleTokenAuth
|
6
7
|
mattr_accessor :user_class
|
7
8
|
mattr_accessor :device_expires_in_days
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module DeviseMultipleTokenAuth
|
2
|
+
module ActionController
|
3
|
+
module API
|
4
|
+
def authenticate_token_user!
|
5
|
+
token = request.env['HTTP_AUTHORIZATION']
|
6
|
+
if token.present? && token.include?("OAuth")
|
7
|
+
token = token.gsub(/^OAuth\s+/, '')
|
8
|
+
end
|
9
|
+
@device = Device.includes(:user).find_by_auth_token(token)
|
10
|
+
if !@device || @device.expired? || @device.user == nil
|
11
|
+
head :unauthorized
|
12
|
+
else
|
13
|
+
@device.expires_at = Time.now + (DeviseMultipleTokenAuth.device_expires_in_days || 14).days
|
14
|
+
@device.save
|
15
|
+
sign_in(@device.user)
|
16
|
+
@current_user = @device.user
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
class ActionController::API
|
24
|
+
include DeviseMultipleTokenAuth::ActionController::API
|
25
|
+
end
|
@@ -6,9 +6,9 @@ module DeviseMultipleTokenAuth
|
|
6
6
|
if token.present? && token.include?("OAuth")
|
7
7
|
token = token.gsub(/^OAuth\s+/, '')
|
8
8
|
end
|
9
|
-
@device = Device.find_by_auth_token(token)
|
9
|
+
@device = Device.includes(:user).find_by_auth_token(token)
|
10
10
|
if !@device || @device.expired? || @device.user == nil
|
11
|
-
|
11
|
+
head :unauthorized
|
12
12
|
else
|
13
13
|
@device.expires_at = Time.now + (DeviseMultipleTokenAuth.device_expires_in_days || 14).days
|
14
14
|
@device.save
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: devise_multiple_token_auth
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.25
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Josh Juncker
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-11-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: 5.0.0
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
26
|
+
version: 5.0.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: devise
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -68,6 +68,7 @@ files:
|
|
68
68
|
- app/models/devise_multiple_token_auth/device.rb
|
69
69
|
- config/routes.rb
|
70
70
|
- lib/devise_multiple_token_auth.rb
|
71
|
+
- lib/devise_multiple_token_auth/action_controller/api.rb
|
71
72
|
- lib/devise_multiple_token_auth/action_controller/base.rb
|
72
73
|
- lib/devise_multiple_token_auth/active_record/base.rb
|
73
74
|
- lib/devise_multiple_token_auth/engine.rb
|
@@ -109,8 +110,6 @@ files:
|
|
109
110
|
- test/dummy/config/locales/en.yml
|
110
111
|
- test/dummy/config/routes.rb
|
111
112
|
- test/dummy/config/secrets.yml
|
112
|
-
- test/dummy/db/development.sqlite3
|
113
|
-
- test/dummy/log/development.log
|
114
113
|
- test/dummy/public/404.html
|
115
114
|
- test/dummy/public/422.html
|
116
115
|
- test/dummy/public/500.html
|
@@ -140,7 +139,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
140
139
|
version: '0'
|
141
140
|
requirements: []
|
142
141
|
rubyforge_project:
|
143
|
-
rubygems_version: 2.4
|
142
|
+
rubygems_version: 2.6.4
|
144
143
|
signing_key:
|
145
144
|
specification_version: 4
|
146
145
|
summary: Multiple device token authentication for devise
|
@@ -174,8 +173,6 @@ test_files:
|
|
174
173
|
- test/dummy/config/routes.rb
|
175
174
|
- test/dummy/config/secrets.yml
|
176
175
|
- test/dummy/config.ru
|
177
|
-
- test/dummy/db/development.sqlite3
|
178
|
-
- test/dummy/log/development.log
|
179
176
|
- test/dummy/public/404.html
|
180
177
|
- test/dummy/public/422.html
|
181
178
|
- test/dummy/public/500.html
|
File without changes
|
File without changes
|