devise_userbin 0.6.0 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5e314c1646c87d1007135c071f79d2f18c9b2778
4
- data.tar.gz: 16fe4f53110ac4c15476aa0eec98e4d672bdd81e
3
+ metadata.gz: 74c13514b787b554dbadad7eca6d1b737660645b
4
+ data.tar.gz: 9d572271db7d6c33536c4cfc3143f639dbbde199
5
5
  SHA512:
6
- metadata.gz: 82836adb7d582a7513a0b605ede8bdef77cff96417b00bfd454489001a3a1167ff167c35255f206f9a27449c0ed22ac71de0d0d7916f0bacbd6fa97ad53c1a2e
7
- data.tar.gz: bdeffb6964effbe01000bc63f4cb135e0494e7be580eb800e3e55042b1b41fb410d57f2d6933f35933e731be798f819ee8e2e34eff6f78fc58962f28c5411773
6
+ metadata.gz: 15a1055c682c6988ab1555c41f9092c498b4a3d39d4fcb0a263f083eedc0cfcfbcbd4b2fb6df85ec797b7a6f736373430479407637080c9df96f81dc20055cb3
7
+ data.tar.gz: 187e7d92904849e389b6106d450d039e5e1fd0a2b434bd8d63ec994c9b138c3b880dc1ed7a97cf418360e497032ec508d446c2b89f808b401db9ab142172f543
@@ -1,24 +1,40 @@
1
+ # Instantiate Userbin client on every request
1
2
  Warden::Manager.on_request do |warden|
2
3
  warden.request.env['userbin'] =
3
4
  Userbin::Client.new(warden.request, warden.cookies)
4
5
  end
5
6
 
7
+ # Track logout.succeeded
6
8
  Warden::Manager.before_logout do |record, warden, opts|
7
9
  if record.respond_to?(:userbin_id)
8
- warden.request.env['userbin'].logout
10
+ userbin = warden.request.env['userbin']
11
+ userbin.logout
12
+ userbin.track(name: 'logout.succeeded')
9
13
  end
10
14
  end
11
15
 
16
+ # Track login.failed
17
+ Warden::Manager.before_failure do |env, opts|
18
+ if opts[:action] == 'unauthenticated'
19
+ userbin = env['userbin']
20
+ userbin.track(name: 'login.failed')
21
+ end
22
+ end
23
+
24
+ # Track login.succeeded
12
25
  Warden::Manager.after_set_user :except => :fetch do |record, warden, opts|
13
26
  if record.respond_to?(:userbin_id)
14
- env = warden.request.env
15
- env['userbin'].login(record._userbin_id, email: record.email)
27
+ userbin = warden.request.env['userbin']
28
+ userbin.track(user_id: record._userbin_id, name: 'login.succeeded')
29
+ userbin.login(record._userbin_id, email: record.email)
16
30
  end
17
31
  end
18
32
 
33
+ # Continous authentication
19
34
  Warden::Manager.after_set_user do |record, warden, opts|
20
35
  if record.respond_to?(:userbin_id)
21
36
  env = warden.request.env
22
- env['userbin'].authorize! unless env['userbin.skip_authorization']
37
+ userbin = env['userbin']
38
+ userbin.authorize! unless env['userbin.skip_authorization']
23
39
  end
24
40
  end
@@ -1,3 +1,3 @@
1
1
  module DeviseUserbin
2
- VERSION = "0.6.0".freeze
2
+ VERSION = "0.7.0".freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: devise_userbin
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Johan Brissmyr
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-11-20 00:00:00.000000000 Z
11
+ date: 2014-12-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: devise
@@ -30,14 +30,14 @@ dependencies:
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: 1.6.1
33
+ version: 1.7.0
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: 1.6.1
40
+ version: 1.7.0
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: bundler
43
43
  requirement: !ruby/object:Gem::Requirement