zas-service 0.0.5 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
@@ -55,9 +55,11 @@ module Zas
|
|
55
55
|
def authenticate(username, password)
|
56
56
|
logger.info "Authenticating #{username} (table: #{table_name}, username_field: #{username_field})" if logger
|
57
57
|
record = db[table_name].filter(username_field => username).first
|
58
|
-
|
59
|
-
|
60
|
-
|
58
|
+
if record
|
59
|
+
logger.info "Record found for #{username}" if logger
|
60
|
+
tokens = [password, record[salt_field]].compact
|
61
|
+
matches?(record[password_field], *tokens)
|
62
|
+
end
|
61
63
|
end
|
62
64
|
|
63
65
|
private
|
data/lib/zas/service.rb
CHANGED
@@ -73,7 +73,7 @@ module Zas
|
|
73
73
|
authenticator = authenticators[req.strategy]
|
74
74
|
raise "No authenticator found for #{req.strategy}" unless authenticator
|
75
75
|
authenticator.logger ||= logger
|
76
|
-
{:authenticated? => authenticator.authenticate(req.credentials)}
|
76
|
+
{:authenticated? => (authenticator.authenticate(req.credentials) || false)}
|
77
77
|
rescue => e
|
78
78
|
logger.info "Error authenticating: #{e.message}"
|
79
79
|
{:error => e.message}
|