Module: TranslationCms::Authenticatable

Extended by:
ActiveSupport::Concern
Included in:
TranslationCms::Api::Customer
Defined in:
lib/translation_cms/authenticatable.rb

Defined Under Namespace

Modules: ClassMethods

Instance Method Summary collapse

Instance Method Details

#active_for_authentication?Boolean

Returns:

  • (Boolean)


59
60
61
# File 'lib/translation_cms/authenticatable.rb', line 59

def active_for_authentication?
  true
end

#after_database_authenticationObject



71
72
73
# File 'lib/translation_cms/authenticatable.rb', line 71

def after_database_authentication
  # RequestStore.store[:access_token] = session.access_token
end

#authenticatable_saltObject



47
# File 'lib/translation_cms/authenticatable.rb', line 47

def authenticatable_salt; end

#inactive_messageObject



63
64
65
# File 'lib/translation_cms/authenticatable.rb', line 63

def inactive_message
  :inactive
end

#unauthenticated_messageObject



67
68
69
# File 'lib/translation_cms/authenticatable.rb', line 67

def unauthenticated_message
  :invalid
end

#valid_for_authentication?Boolean

Check if the current object is valid for authentication. This method and find_for_authentication are the methods used in a Warden::Strategy to check if a model should be signed in or not.

However, you should not overwrite this method, you should overwrite active_for_authentication? and inactive_message instead.

Returns:

  • (Boolean)


55
56
57
# File 'lib/translation_cms/authenticatable.rb', line 55

def valid_for_authentication?
  block_given? ? yield : true
end

#valid_password?(password) ⇒ Boolean

Returns:

  • (Boolean)


75
76
77
# File 'lib/translation_cms/authenticatable.rb', line 75

def valid_password?(password)
  password.present? && token.present? && session.errors.empty?
end