Sha256: d309e0a7186e7863a1a70206281a23da5c8f81e4bc34166e6ceb77c694bd378d

Contents?: true

Size: 1.01 KB

Versions: 1

Compression:

Stored size: 1.01 KB

Contents

require_relative '../lib/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

1 entries across 1 versions & 1 rubygems

Version Path
authn-2.4.0 test/helper.rb