0

我正在尝试设置我的应用程序以使用 Sorcery。当我添加authenticates_with_sorcery!到我的用户模型时,我的规范开始运行非常慢(大约每秒一个)。是否有某种配置或设置可能导致巫术出现这种情况?

这是我的用户模型:

# This model represents a user of the application, disregarding that person's use of the system. For
# instance, a user could be a job hunter, an employer, an administrator, or some other stakeholder.
class User < ActiveRecord::Base
  authenticates_with_sorcery!

  attr_accessible :email, :password, :password_confirmation

  # validations
  validates :email, 
            :presence => true, 
            :uniqueness => true, 
            :format => /[^@]+@[^@]+\.[^@]+/

  validates :password, :presence => true, :confirmation => true

  validates :password_confirmation, :presence => true

  # before filters
  before_save :sanitize_email

  private

  # Strips and removes HTML tags from the email parameter.
  def sanitize_email
    self.email = email.strip

    # remove anything that looks like an email
    self.email = email.gsub(/<[^<>]+>/, "")
  end
end

和我的用户工厂:

require 'factory_girl'
require 'ffaker'

FactoryGirl.define do

  sequence :email do |n|
    "email#{n}@example.com"
  end

  factory :user do |f|
    email
    password "password"
    password_confirmation "password"
  end
end
4

1 回答 1

2

我的第一个猜测是慢速密码加密。例如在设计中我们有config.stretches配置变量,在测试环境中可以设置为一个小数字。

检查设计的database_authenticable的“延伸”是什么意思?

于 2012-11-23T08:57:11.523 回答