Sha256: ab041e42ad8670201071f0077a5974d0e29921dc9ba3e7ed862f761d98794703

Contents?: true

Size: 1019 Bytes

Versions: 3

Compression:

Stored size: 1019 Bytes

Contents

require 'authn'

module ActiveModel::Model
  def self.included(base)
    base.class_eval do
      extend  ActiveModel::Naming
      extend  ActiveModel::Translation
      include ActiveModel::Validations
      include ActiveModel::Conversion
      include ActiveModel::SecurePassword
    end
  end

  def initialize(params={})
    params.each do |attr, value|
      self.public_send("#{attr}=", value)
    end if params
  end

  def persisted?
    false
  end
end

class Account
  include ActiveModel::Model
  include AuthN::Model
  has_authentication
  has_secure_password
  attr_accessor :password_digest

  def self.password(password=nil)
    if password
      @password = password
    else
      @password
    end
  end

  def self.where(hash)
    account = if hash[:email] == "kurtis@example.com"
      Account.new(password: password, password_confirmation: password)
    end
    [account]
  end

  def id
    @id ||= rand(100000)
  end
end


class Controller
  include AuthN::Session
  attr_accessor :session
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
authn-3.1.4 test/helper.rb
authn-3.1.0 test/helper.rb
authn-2.6.0 test/helper.rb