module Yellin::ActsAsUser::ClassMethods

Public Class Methods

digest(string) click to toggle source
# File lib/yellin/acts_as_user.rb, line 19
def self.digest(string)
  cost = ActiveModel::SecurePassword.min_cost ? BCrypt::Engine::MIN_COST : BCrypt::Engine.cost
  BCrypt::Password.create(string, cost: cost)
end
new_token() click to toggle source
# File lib/yellin/acts_as_user.rb, line 24
def self.new_token
  SecureRandom.urlsafe_base64
end

Public Instance Methods

acts_as_user() click to toggle source
# File lib/yellin/acts_as_user.rb, line 9
def acts_as_user
  attr_accessor :remember_token, :activation_token, :reset_token
  has_secure_password
  before_save :downcase_email
  before_create :create_activation_digest
  validates :password, presence: true, length: { minimum: Yellin.password_minimum_length }, allow_nil: true
  # See https://davidcel.is/posts/stop-validating-email-addresses-with-regex/ for regex reasoning
  validates :email, presence: true, length: { maximum: 255 }, format: { with: /@/ },
                    uniqueness: { case_sensitive: false }

  def self.digest(string)
    cost = ActiveModel::SecurePassword.min_cost ? BCrypt::Engine::MIN_COST : BCrypt::Engine.cost
    BCrypt::Password.create(string, cost: cost)
  end

  def self.new_token
    SecureRandom.urlsafe_base64
  end

  include Yellin::ActsAsUser::LocalInstanceMethods
end