devise_custom_authenticatable 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Simple way how to customize devise authentication logic and still be inline with all other devise parts
4
4
 
5
- Extends Devise with new module `:custom_authenticatable`, when used it will call `#valid_for_model_authentication?` method on resource model with password if such defined. Return true in order to authenticate user. If method isn't defined for model or return false/nil then authentication handling will be passed to next strategy e.g. `:database_authenticatable`, if there is no other strategies for resource left then authentication will be failed.
5
+ Extends Devise with new module `:custom_authenticatable`, when enabled it will try to call `#valid_for_custom_authentication?` method on resource model with password. Define this method and return true in order to authenticate user. If method isn't defined for model or returns false/nil then authentication handling will be passed to next strategy e.g. `:database_authenticatable`, if there is no other strategies left for resource then authentication will be failed.
6
6
 
7
7
  ## Installation
8
8
 
@@ -9,7 +9,7 @@ Gem::Specification.new do |spec|
9
9
  spec.authors = ["Artūrs Mekšs"]
10
10
  spec.email = ["arturs.mekss@gmail.com"]
11
11
  spec.description = %q{Simple way to customize devise authentication logic and still be inline with all other devise parts}
12
- spec.summary = %q{Extends Devise with new module :custom_authenticatable, when used it will call #valid_for_model_authentication? method on resource model with password if such defined. Return true in order to authenticate user. If method isn't defined for model or return false/nil then authentication handling will be passed to next strategy e.g. :database_authenticatable, if there is no other strategies for resource then authentication will be failed}
12
+ spec.summary = %q{Extends Devise with new module :custom_authenticatable, when enabled it will call #valid_for_custom_authentication? method on resource model for your customizations}
13
13
  spec.homepage = "https://github.com/AMekss/devise_custom_authenticatable"
14
14
  spec.license = "MIT"
15
15
 
@@ -6,10 +6,7 @@ module Devise::Strategies
6
6
 
7
7
  def authenticate!
8
8
  resource = valid_password? && mapping.to.find_for_authentication(authentication_hash)
9
-
10
- unless resource.respond_to?(:valid_for_custom_authentication?)
11
- return pass
12
- end
9
+ return pass unless resource.respond_to?(:valid_for_custom_authentication?)
13
10
 
14
11
  if validate(resource){ resource.valid_for_custom_authentication?(password) }
15
12
  success!(resource)
@@ -18,6 +15,18 @@ module Devise::Strategies
18
15
  end
19
16
  end
20
17
 
18
+ # Override default Devise::Strategies::Authenticatable#validate method in order to *not* return fail! on flase,
19
+ # but pass handling to other strategies in stack, e.g default :database_authenticatable or other similar
20
+ # authentication will be failed with default message anyway if there are no strategies left
21
+ def validate(resource, &block)
22
+ if resource && resource.valid_for_authentication?(&block)
23
+ decorate(resource)
24
+ true
25
+ else
26
+ false
27
+ end
28
+ end
29
+
21
30
  end
22
31
  end
23
32
 
@@ -1,3 +1,3 @@
1
1
  module DeviseCustomAuthenticatable
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
metadata CHANGED
@@ -1,18 +1,20 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: devise_custom_authenticatable
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
+ prerelease:
5
6
  platform: ruby
6
7
  authors:
7
8
  - Artūrs Mekšs
8
9
  autorequire:
9
10
  bindir: bin
10
11
  cert_chain: []
11
- date: 2014-01-26 00:00:00.000000000 Z
12
+ date: 2014-01-29 00:00:00.000000000 Z
12
13
  dependencies:
13
14
  - !ruby/object:Gem::Dependency
14
15
  name: bundler
15
16
  requirement: !ruby/object:Gem::Requirement
17
+ none: false
16
18
  requirements:
17
19
  - - ~>
18
20
  - !ruby/object:Gem::Version
@@ -20,6 +22,7 @@ dependencies:
20
22
  type: :development
21
23
  prerelease: false
22
24
  version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
23
26
  requirements:
24
27
  - - ~>
25
28
  - !ruby/object:Gem::Version
@@ -27,34 +30,39 @@ dependencies:
27
30
  - !ruby/object:Gem::Dependency
28
31
  name: rake
29
32
  requirement: !ruby/object:Gem::Requirement
33
+ none: false
30
34
  requirements:
31
- - - '>='
35
+ - - ! '>='
32
36
  - !ruby/object:Gem::Version
33
37
  version: '0'
34
38
  type: :development
35
39
  prerelease: false
36
40
  version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
37
42
  requirements:
38
- - - '>='
43
+ - - ! '>='
39
44
  - !ruby/object:Gem::Version
40
45
  version: '0'
41
46
  - !ruby/object:Gem::Dependency
42
47
  name: rspec
43
48
  requirement: !ruby/object:Gem::Requirement
49
+ none: false
44
50
  requirements:
45
- - - '>='
51
+ - - ! '>='
46
52
  - !ruby/object:Gem::Version
47
53
  version: '0'
48
54
  type: :development
49
55
  prerelease: false
50
56
  version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
51
58
  requirements:
52
- - - '>='
59
+ - - ! '>='
53
60
  - !ruby/object:Gem::Version
54
61
  version: '0'
55
62
  - !ruby/object:Gem::Dependency
56
63
  name: devise
57
64
  requirement: !ruby/object:Gem::Requirement
65
+ none: false
58
66
  requirements:
59
67
  - - ~>
60
68
  - !ruby/object:Gem::Version
@@ -62,6 +70,7 @@ dependencies:
62
70
  type: :runtime
63
71
  prerelease: false
64
72
  version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
65
74
  requirements:
66
75
  - - ~>
67
76
  - !ruby/object:Gem::Version
@@ -91,32 +100,29 @@ files:
91
100
  homepage: https://github.com/AMekss/devise_custom_authenticatable
92
101
  licenses:
93
102
  - MIT
94
- metadata: {}
95
103
  post_install_message:
96
104
  rdoc_options: []
97
105
  require_paths:
98
106
  - lib
99
107
  required_ruby_version: !ruby/object:Gem::Requirement
108
+ none: false
100
109
  requirements:
101
- - - '>='
110
+ - - ! '>='
102
111
  - !ruby/object:Gem::Version
103
112
  version: '0'
104
113
  required_rubygems_version: !ruby/object:Gem::Requirement
114
+ none: false
105
115
  requirements:
106
- - - '>='
116
+ - - ! '>='
107
117
  - !ruby/object:Gem::Version
108
118
  version: '0'
109
119
  requirements: []
110
120
  rubyforge_project:
111
- rubygems_version: 2.2.1
121
+ rubygems_version: 1.8.25
112
122
  signing_key:
113
- specification_version: 4
114
- summary: 'Extends Devise with new module :custom_authenticatable, when used it will
115
- call #valid_for_model_authentication? method on resource model with password if
116
- such defined. Return true in order to authenticate user. If method isn''t defined
117
- for model or return false/nil then authentication handling will be passed to next
118
- strategy e.g. :database_authenticatable, if there is no other strategies for resource
119
- then authentication will be failed'
123
+ specification_version: 3
124
+ summary: ! 'Extends Devise with new module :custom_authenticatable, when enabled it
125
+ will call #valid_for_custom_authentication? method on resource model for your customizations'
120
126
  test_files:
121
127
  - spec/devise/models/custom_authenticatable_spec.rb
122
128
  - spec/spec_helper.rb
checksums.yaml DELETED
@@ -1,7 +0,0 @@
1
- ---
2
- SHA1:
3
- metadata.gz: 5199866fec3da5794d0ad77e0c99b7270da070c2
4
- data.tar.gz: 5a4fbcdd35b2e525e640850f92121376d313e69c
5
- SHA512:
6
- metadata.gz: f3fcc76c27370b571b068f3dcaccf32eb96eaf07205fc4f5854edeeb6965cbb4fc2455fadf1567c07d3354f211b8edc18e88c2c1d9a0e9f541da8772bdf30576
7
- data.tar.gz: d44cf55749739078861cfbbeabd330c9339e4c59ed70d6dfdc8952440b8c2a22a06426996d919ec9105adaea821f585101efb0c3160e5d262fb8b1a834089a90