class Auther::Authenticator
Manages account authentication.
Attributes
Public Class Methods
Source
# File lib/auther/authenticator.rb, line 7 def initialize secret, account_model, account_presenter, logger: LOGGER @cipher = Auther::Cipher.new secret @account_model = account_model @account_presenter = account_presenter @logger = logger end
rubocop:disable Metrics/ParameterLists
Public Instance Methods
Source
# File lib/auther/authenticator.rb, line 15 def authenticated? account_model.valid? && account_presenter.valid? && authentic_name? && authentic_login? && authentic_password? end
rubocop:enable Metrics/ParameterLists
Private Instance Methods
Source
# File lib/auther/authenticator.rb, line 32 def authentic? encrypted_value, value, error_name if cipher.decrypt(encrypted_value) == value true else account_presenter.errors.add error_name, "is invalid" false end rescue ActiveSupport::MessageEncryptor::InvalidMessage log_info %(Authentication failed! Invalid credential(s) for "#{account_model.name}" account.) false end
Source
# File lib/auther/authenticator.rb, line 46 def authentic_login? authentic? account_model.encrypted_login, account_presenter.login, "login" end
Source
# File lib/auther/authenticator.rb, line 44 def authentic_name? = account_presenter.name == account_model.name def authentic_login? authentic? account_model.encrypted_login, account_presenter.login, "login" end def authentic_password? authentic? account_model.encrypted_password, account_presenter.password, "password" end end
Source
# File lib/auther/authenticator.rb, line 50 def authentic_password? authentic? account_model.encrypted_password, account_presenter.password, "password" end
Source
# File lib/auther/authenticator.rb, line 27 def log_info message id = "[#{Auther::Keymaster.namespace}]" logger.info [id, message].join(": ") end