devise_castle 1.3.2 → 1.3.4

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: fed2b4bde70c3fb648b8b73ba596ddae8c57c87c
4
- data.tar.gz: 4235c9af1d89be5575a18c8247f0afc2c4f51e93
3
+ metadata.gz: b2f22f6ada2c44ff3db71806b63389b1ab3effbd
4
+ data.tar.gz: 9a7908fc9fd6f1dd802a8d190b798924a6fc731a
5
5
  SHA512:
6
- metadata.gz: fa706cce1ce7efdf2e096ebf71b783106aed6595cfd4153a68be8c33ab6aebd9d81e51ae6c0dd4ac4e103ed051438f6dc314be5f8dc3751cb872f86ac77b59c0
7
- data.tar.gz: 31eb367a77bef0ad819a3c15d20267755a41ad06cefab41d15f00f5496040d968e5fcdd47ff4704b6ec54ee8d0142891e6ba82b245ffe9251440da3b2cd5ccb6
6
+ metadata.gz: e164170c07efabe7eddd0f26dfc753c598ee3fd6a61af621d031edf3ee338aa7d3b7cae6ca2e3315856de5a651c64775ec04f6a5f38ab1ffc65794a6ad2e6552
7
+ data.tar.gz: 0877d062f9ed3a9025b940118bfbb9998aa147b0c0c2d31b0b831759c7abe43e9cfa6695e80ca3942b8c2f1fee78fd67864d9ef03712be6835cec65bf78c39a5
@@ -11,11 +11,17 @@ class DeviseCastle::PasswordsController < Devise::PasswordsController
11
11
  super do |resource|
12
12
  return if resource.respond_to?(:castle_do_not_track?) && resource.castle_do_not_track?
13
13
 
14
- castle.track(
15
- name: '$password_reset.requested',
16
- details: {
17
- '$login' => username
18
- })
14
+ begin
15
+ castle.track(
16
+ name: '$password_reset.requested',
17
+ details: {
18
+ '$login' => username
19
+ })
20
+ rescue ::Castle::Error => e
21
+ if Devise.castle_error_handler.is_a?(Proc)
22
+ Devise.castle_error_handler.call(e)
23
+ end
24
+ end
19
25
  end
20
26
  end
21
27
 
@@ -23,14 +29,20 @@ class DeviseCastle::PasswordsController < Devise::PasswordsController
23
29
  super do |resource|
24
30
  return if resource.respond_to?(:castle_do_not_track?) && resource.castle_do_not_track?
25
31
 
26
- if resource.errors.empty?
27
- castle.track(
28
- name: '$password_reset.succeeded',
29
- user_id: resource._castle_id)
30
- else
31
- castle.track(
32
- name: '$password_reset.failed',
33
- user_id: resource._castle_id)
32
+ begin
33
+ if resource.errors.empty?
34
+ castle.track(
35
+ name: '$password_reset.succeeded',
36
+ user_id: resource._castle_id)
37
+ else
38
+ castle.track(
39
+ name: '$password_reset.failed',
40
+ user_id: resource._castle_id)
41
+ end
42
+ rescue ::Castle::Error => e
43
+ if Devise.castle_error_handler.is_a?(Proc)
44
+ Devise.castle_error_handler.call(e)
45
+ end
34
46
  end
35
47
  end
36
48
  end
@@ -3,13 +3,19 @@ class DeviseCastle::RegistrationsController < Devise::RegistrationsController
3
3
 
4
4
  def create
5
5
  super do |resource|
6
- if resource.persisted?
7
- castle.track(
8
- name: '$registration.succeeded',
9
- user_id: resource._castle_id)
10
- else
11
- castle.track(
12
- name: '$registration.failed')
6
+ begin
7
+ if resource.persisted?
8
+ castle.track(
9
+ name: '$registration.succeeded',
10
+ user_id: resource._castle_id)
11
+ else
12
+ castle.track(
13
+ name: '$registration.failed')
14
+ end
15
+ rescue ::Castle::Error => e
16
+ if Devise.castle_error_handler.is_a?(Proc)
17
+ Devise.castle_error_handler.call(e)
18
+ end
13
19
  end
14
20
  end
15
21
  end
@@ -17,15 +23,21 @@ class DeviseCastle::RegistrationsController < Devise::RegistrationsController
17
23
  def update_resource(resource, params)
18
24
  resource_updated = super
19
25
 
20
- if params['password'].present?
21
- if resource_updated
22
- castle.track(
23
- name: '$password_change.succeeded',
24
- user_id: resource._castle_id)
25
- else
26
- castle.track(
27
- name: '$password_change.failed',
28
- user_id: resource._castle_id)
26
+ begin
27
+ if params['password'].present?
28
+ if resource_updated
29
+ castle.track(
30
+ name: '$password_change.succeeded',
31
+ user_id: resource._castle_id)
32
+ else
33
+ castle.track(
34
+ name: '$password_change.failed',
35
+ user_id: resource._castle_id)
36
+ end
37
+ end
38
+ rescue ::Castle::Error => e
39
+ if Devise.castle_error_handler.is_a?(Proc)
40
+ Devise.castle_error_handler.call(e)
29
41
  end
30
42
  end
31
43
 
@@ -9,7 +9,13 @@ Warden::Manager.before_logout do |record, warden, opts|
9
9
  if record.respond_to?(:castle_id)
10
10
  unless record.respond_to?(:castle_do_not_track?) && record.castle_do_not_track?
11
11
  castle = warden.request.env['castle']
12
- castle.track(user_id: record._castle_id, name: '$logout.succeeded')
12
+ begin
13
+ castle.track(user_id: record._castle_id, name: '$logout.succeeded')
14
+ rescue ::Castle::Error => e
15
+ if Devise.castle_error_handler.is_a?(Proc)
16
+ Devise.castle_error_handler.call(e)
17
+ end
18
+ end
13
19
  end
14
20
  end
15
21
  end
@@ -23,12 +29,18 @@ Warden::Manager.before_failure do |env, opts|
23
29
  end
24
30
 
25
31
  castle = env['castle']
26
- castle.track(
27
- name: '$login.failed',
28
- user_id: user_id,
29
- details: {
30
- '$login' => opts[:username]
31
- })
32
+ begin
33
+ castle.track(
34
+ name: '$login.failed',
35
+ user_id: user_id,
36
+ details: {
37
+ '$login' => opts[:username]
38
+ })
39
+ rescue ::Castle::Error => e
40
+ if Devise.castle_error_handler.is_a?(Proc)
41
+ Devise.castle_error_handler.call(e)
42
+ end
43
+ end
32
44
  end
33
45
  end
34
46
 
@@ -37,10 +49,13 @@ Warden::Manager.after_set_user :except => :fetch do |record, warden, opts|
37
49
  if record.respond_to?(:castle_id)
38
50
  unless record.respond_to?(:castle_do_not_track?) && record.castle_do_not_track?
39
51
  castle = warden.request.env['castle']
40
- castle.identify(record._castle_id, {
41
- email: record.email
42
- })
43
- castle.track(user_id: record._castle_id, name: '$login.succeeded')
52
+ begin
53
+ castle.track(user_id: record._castle_id, name: '$login.succeeded')
54
+ rescue ::Castle::Error => e
55
+ if Devise.castle_error_handler.is_a?(Proc)
56
+ Devise.castle_error_handler.call(e)
57
+ end
58
+ end
44
59
  end
45
60
  end
46
61
  end
@@ -1,3 +1,3 @@
1
1
  module DeviseCastle
2
- VERSION = "1.3.2".freeze
2
+ VERSION = "1.3.4".freeze
3
3
  end
data/lib/devise_castle.rb CHANGED
@@ -7,7 +7,9 @@ require 'castle-rb'
7
7
 
8
8
  module Devise
9
9
  mattr_accessor :castle_api_secret
10
+ mattr_accessor :castle_error_handler
10
11
  @@castle_api_secret = ''
12
+ @@castle_error_handler = nil
11
13
  end
12
14
 
13
15
  module DeviseCastle
@@ -18,6 +18,10 @@ module DeviseCastle
18
18
  # ==> Configuration for :castle
19
19
  config.castle_api_secret = '#{api_secret}'
20
20
 
21
+ # config.castle_error_handler = Proc.new { |exception|
22
+ # # Handle error from Castle
23
+ # }
24
+
21
25
  CONTENT
22
26
  end
23
27
  end
metadata CHANGED
@@ -1,14 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: devise_castle
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.2
4
+ version: 1.3.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Johan Brissmyr
8
+ - Sebastian Wallin
8
9
  autorequire:
9
10
  bindir: bin
10
11
  cert_chain: []
11
- date: 2016-03-02 00:00:00.000000000 Z
12
+ date: 2016-04-04 00:00:00.000000000 Z
12
13
  dependencies:
13
14
  - !ruby/object:Gem::Dependency
14
15
  name: devise
@@ -30,14 +31,14 @@ dependencies:
30
31
  requirements:
31
32
  - - "~>"
32
33
  - !ruby/object:Gem::Version
33
- version: 1.2.5
34
+ version: 1.2.13
34
35
  type: :runtime
35
36
  prerelease: false
36
37
  version_requirements: !ruby/object:Gem::Requirement
37
38
  requirements:
38
39
  - - "~>"
39
40
  - !ruby/object:Gem::Version
40
- version: 1.2.5
41
+ version: 1.2.13
41
42
  - !ruby/object:Gem::Dependency
42
43
  name: bundler
43
44
  requirement: !ruby/object:Gem::Requirement
@@ -127,3 +128,4 @@ signing_key:
127
128
  specification_version: 4
128
129
  summary: Devise extension for Castle
129
130
  test_files: []
131
+ has_rdoc: