pipa-authmagic 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -13,6 +13,11 @@ module Authmagic
|
|
13
13
|
|
14
14
|
cfg = @context.config.principal_config
|
15
15
|
login = cfg.fetch(:login_field, :login)
|
16
|
+
case_sensitive = case cfg.fetch(:compare, :case_sensitive)
|
17
|
+
when :case_sensitive then true
|
18
|
+
when :case_insensitive then false
|
19
|
+
else raise 'bad :compare value'
|
20
|
+
end
|
16
21
|
password = cfg.fetch(:password_field, :password)
|
17
22
|
password_set = :"#{password}="
|
18
23
|
password_valid = :"#{password}_valid?"
|
@@ -33,7 +38,10 @@ module Authmagic
|
|
33
38
|
|
34
39
|
principal.class_eval do
|
35
40
|
self.class.send(:define_method, :authenticate) do |options|
|
36
|
-
|
41
|
+
conditions = case_sensitive ?
|
42
|
+
{login => options[login]} :
|
43
|
+
["lower(#{connection.quote_column_name(login)}) = lower(?)", options[login]]
|
44
|
+
returning first(:conditions => conditions) do |p|
|
37
45
|
raise AccountNotFound unless p
|
38
46
|
raise BadPassword unless p.send(password_valid, options[password])
|
39
47
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pipa-authmagic
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Igor Gunko
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2008-12-
|
12
|
+
date: 2008-12-27 00:00:00 -08:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|