devise_castle 1.2.0 → 1.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/devise_castle/passwords_controller.rb +33 -0
- data/app/controllers/devise_castle/registrations_controller.rb +34 -0
- data/lib/devise_castle/mapping.rb +2 -0
- data/lib/devise_castle/version.rb +1 -1
- data/lib/generators/devise_castle/devise_castle_generator.rb +16 -0
- metadata +6 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cc0769f06d1d122c8aebf39d946c3c4b2ce20f5d
|
4
|
+
data.tar.gz: be354869d44b0836832793cf49dc4411ebd3127f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3ced01a712218d7609649797a0b527e7e039fc0a03615aa5b73539438674509df1e4768068ff2c2ac394aa9c151adbbe8bdd2fcb57cc7f6bd00e1f7ba6013161
|
7
|
+
data.tar.gz: bd3341242d82c3b901e55420c2dde215f79d39105369cbabadfc3e8d0be5182b0b0ce878183711783c9450b879c921893cd1749ebfb9bfa3be99baeec8397aff
|
@@ -0,0 +1,33 @@
|
|
1
|
+
class DeviseCastle::PasswordsController < Devise::PasswordsController
|
2
|
+
unloadable unless Rails.version =~/^4/
|
3
|
+
|
4
|
+
def create
|
5
|
+
key = resource_params.keys.first
|
6
|
+
|
7
|
+
username = if Devise.reset_password_keys.include?(key.to_sym)
|
8
|
+
resource_params.values.first
|
9
|
+
end
|
10
|
+
|
11
|
+
super do |resource|
|
12
|
+
castle.track(
|
13
|
+
name: '$password_reset.requested',
|
14
|
+
details: {
|
15
|
+
'$login' => username
|
16
|
+
})
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def update
|
21
|
+
super do |resource|
|
22
|
+
if resource.errors.empty?
|
23
|
+
castle.track(
|
24
|
+
name: '$password_reset.succeeded',
|
25
|
+
user_id: resource._castle_id)
|
26
|
+
else
|
27
|
+
castle.track(
|
28
|
+
name: '$password_reset.failed',
|
29
|
+
user_id: resource._castle_id)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
class DeviseCastle::RegistrationsController < Devise::RegistrationsController
|
2
|
+
unloadable unless Rails.version =~/^4/
|
3
|
+
|
4
|
+
def create
|
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')
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def update_resource(resource, params)
|
18
|
+
resource_updated = super
|
19
|
+
|
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)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
resource_updated
|
33
|
+
end
|
34
|
+
end
|
@@ -8,6 +8,8 @@ module DeviseCastle
|
|
8
8
|
def default_controllers_with_castle(options)
|
9
9
|
options[:controllers] ||= {}
|
10
10
|
options[:controllers][:sessions] ||= "devise_castle/sessions"
|
11
|
+
options[:controllers][:registrations] ||= "devise_castle/registrations"
|
12
|
+
options[:controllers][:passwords] ||= "devise_castle/passwords"
|
11
13
|
default_controllers_without_castle(options)
|
12
14
|
end
|
13
15
|
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module DeviseCastle
|
2
|
+
module Generators
|
3
|
+
class DeviseCastleGenerator < Rails::Generators::NamedBase
|
4
|
+
namespace "devise_castle"
|
5
|
+
|
6
|
+
desc "Add :castle directive in the given model. Also generate migration for ActiveRecord"
|
7
|
+
|
8
|
+
def inject_devise_castle_content
|
9
|
+
path = File.join("app", "models", "#{file_path}.rb")
|
10
|
+
if File.exists?(path)
|
11
|
+
inject_into_file(path, "castle, :", :after => "devise :")
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: devise_castle
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.3.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: 2015-
|
11
|
+
date: 2015-09-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: devise
|
@@ -88,6 +88,8 @@ extensions: []
|
|
88
88
|
extra_rdoc_files: []
|
89
89
|
files:
|
90
90
|
- app/controllers/devise/devise_castle_controller.rb
|
91
|
+
- app/controllers/devise_castle/passwords_controller.rb
|
92
|
+
- app/controllers/devise_castle/registrations_controller.rb
|
91
93
|
- app/controllers/devise_castle/sessions_controller.rb
|
92
94
|
- lib/devise_castle.rb
|
93
95
|
- lib/devise_castle/controllers/helpers.rb
|
@@ -97,6 +99,7 @@ files:
|
|
97
99
|
- lib/devise_castle/railtie.rb
|
98
100
|
- lib/devise_castle/routes.rb
|
99
101
|
- lib/devise_castle/version.rb
|
102
|
+
- lib/generators/devise_castle/devise_castle_generator.rb
|
100
103
|
- lib/generators/devise_castle/install_generator.rb
|
101
104
|
homepage: https://github.com/castle/devise_castle
|
102
105
|
licenses:
|
@@ -118,7 +121,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
118
121
|
version: '0'
|
119
122
|
requirements: []
|
120
123
|
rubyforge_project:
|
121
|
-
rubygems_version: 2.4.
|
124
|
+
rubygems_version: 2.4.5.1
|
122
125
|
signing_key:
|
123
126
|
specification_version: 4
|
124
127
|
summary: Devise extension for Castle
|