lib/authgasm/session/callbacks.rb in authgasm-0.10.1 vs lib/authgasm/session/callbacks.rb in authgasm-0.10.2
- old
+ new
@@ -5,11 +5,11 @@
# Just like in ActiveRecord you have before_save, before_validation, etc. You have similar callbacks with Authgasm, see all callbacks below.
module Callbacks
CALLBACKS = %w(before_create after_create before_destroy after_destroy before_save after_save before_update after_update before_validation after_validation)
def self.included(base) #:nodoc:
- [:destroy, :save, :valid?].each do |method|
+ [:destroy, :save, :valid?, :validate_credentials].each do |method|
base.send :alias_method_chain, method, :callbacks
end
base.send :include, ActiveSupport::Callbacks
base.define_callbacks *CALLBACKS
@@ -39,17 +39,18 @@
run_callbacks(:after_save)
end
result
end
- def valid_with_callbacks? # :nodoc:
- run_callbacks(:before_validation)
+ def valid_with_callbacks?
result = valid_without_callbacks?
- if result
- run_callbacks(:after_validation)
- result = errors.empty?
- end
+ run_callbacks(:after_validation) if result
result
+ end
+
+ def validate_credentials_with_callbacks # :nodoc:
+ run_callbacks(:before_validation)
+ validate_credentials_without_callbacks
end
end
end
end
\ No newline at end of file