diff --git a/lib/devise/models/token_authenticatable.rb b/lib/devise/models/token_authenticatable.rb index 62081c58..852a695e 100644 --- a/lib/devise/models/token_authenticatable.rb +++ b/lib/devise/models/token_authenticatable.rb @@ -27,6 +27,14 @@ module Devise module TokenAuthenticatable extend ActiveSupport::Concern + module ModuleMethods + extend self + + def required_fields + [:authentication_token] + end + end + # Generate new authentication token (a.k.a. "single access token"). def reset_authentication_token self.authentication_token = self.class.authentication_token diff --git a/test/models/token_authenticatable_test.rb b/test/models/token_authenticatable_test.rb index 4ef99d20..f31887cb 100644 --- a/test/models/token_authenticatable_test.rb +++ b/test/models/token_authenticatable_test.rb @@ -46,4 +46,10 @@ class TokenAuthenticatableTest < ActiveSupport::TestCase user = User.find_for_token_authentication(:auth_token => {'$ne' => user1.authentication_token}) assert_nil user end + + test 'required_fields should contain the fields that Devise uses' do + assert_equal Devise::Models::TokenAuthenticatable::ModuleMethods.required_fields.sort, [ + :authentication_token + ] + end end