Sha256: 7de98b2c791d18d2276a5708dd738cd53a01ff51747a8d283b3e31a1a234f6af
Contents?: true
Size: 1.18 KB
Versions: 1
Compression:
Stored size: 1.18 KB
Contents
module Landable AuthenticationFailedError = Class.new(StandardError) module AuthenticationService def self.call(username, password) strategies = Landable.configuration.authenticators strategies.each do |strategy| ident = strategy.call username, password return ident if ident end fail AuthenticationFailedError end class EchoAuthenticator def self.call(username, password) new(nil, nil).call(username, password) end def initialize(username, password) @username = username @password = password end def call(username, password) return unless acceptable_environment? return echo_author(username) if @username.nil? && password != 'fail' return echo_author(username) if @username == username && @password == password end private def acceptable_environment? defined?(::Rails) && (Rails.env.development? || Rails.env.test?) end def echo_author(username) { username: username, email: "#{username}@example.com", first_name: 'Trogdor', last_name: 'McBurninator', groups: ['Publisher'] } end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
landable-1.14.0 | app/services/landable/authentication_service.rb |