Authlogicactivefieldtoactivated_atfield”改写成中文。
创始人
2024-09-22 15:30:11
0

将Authlogic中默认的用户激活字段active更改为activated_at字段。

在用户模型中,将active字段更改为activated_at:

# app/models/user.rb
class User < ApplicationRecord
  acts_as_authentic do |c|
    c.logged_in_timeout = 1.hour
    # Change active field to activated_at field
    c.transition_from_crypto_providers = [Authlogic::CryptoProviders::Sha512]
    c.crypto_provider = Authlogic::CryptoProviders::SCrypt
    c.transition_validation_class = User::TransitionValidation
    c.validate_email_field = false
    c.validate_login_field = false
    c.validate_password_field = false
    c.validate_password_confirmation_field = false

    # Add activation logic to User model
    c.transition_with = User::Transition
    c.transition_class = User::StatefulTransition
    c.activation_token_field = :activation_token
    c.activation_token_sent_at_field = :activation_email_sent_at
    c.activation_token_lifetime = :none
    c.activation_mailer = UserMailer
    c.activation_required = true
    c.disable_perishable_token_maintenance = false
    # Change active field to activated_at field
    c.activation_field = :activated_at
  end
  ...
end

需要同时更新数据库中的迁移文件:

# db/migrate/20191012051200_authlogic.rb
class Authlogic < ActiveRecord::Migration[5.2]
  def change
    add_column :users, :crypted_password, :string
    add_column :users, :password_salt, :string
    remove_column :users, :password, :string
    remove_column :users, :password_confirmation, :string
    remove_column :users, :persistence_token, :string
    remove_column :users, :single_access_token, :string
    remove_column :users, :perishable_token, :string
    remove_column :users, :login_count, :integer
    remove_column :users, :failed_login_count, :integer
    remove_column :users, :last_request_at, :datetime
    remove_column :users, :current_login_at, :datetime
    remove_column :users, :last_login_at, :datetime
    remove_column :users, :current_login_ip, :string
    remove_column :users, :last_login_ip, :string
    # Add activated_at field
    add_column :users, :activated_at, :datetime
    # Add activation_token and activation_email_sent_at fields
    add_column :users, :activation_token, :string
    add_column :users, :activation_email_sent_at, :datetime
  end
end

相关内容

热门资讯

受玩家影响!哈糖大菠萝能开挂吗... 受玩家影响!哈糖大菠萝能开挂吗,智星德州插件怎么下载,都是确实有挂(存在有挂)暗藏猫腻,小编详细说明...
有玩家发现!wepoker私人... 有玩家发现!wepoker私人局外卦,德普之星透视辅助软件是真的吗,原来真的有挂(有挂存在)1、金币...
教学辅助挂!wepoker有辅... 教学辅助挂!wepoker有辅助工具吗,智星德州辅助译码插件靠谱吗,一直是真的有挂(了解有挂)1、进...
2026版总结!hhpoker... 2026版总结!hhpoker脚本下载,德普之星辅助工具如何打开,切实真的是有挂(有挂教程)1、该软...
推出新举措!悦扑克脚本,德普之... 推出新举措!悦扑克脚本,德普之星透视辅助,果然确实有挂(有挂秘诀)亲,关键说明,德普之星透视辅助透视...
今天上午!wepoker辅助器... 今天上午!wepoker辅助器软件下载,德普之星私人局透视,都是是有挂(有挂实锤)1)德普之星私人局...
攻略辅助挂!wpk有辅助器吗,... 攻略辅助挂!wpk有辅助器吗,德普之星透视辅助软件是真的吗,本来存在有挂(新版有挂)亲,关键说明,德...
据目击者称!xpoker辅助助... 据目击者称!xpoker辅助助手,德普之星透视辅助软件下载,一直真的有挂(有挂详情)进入游戏-大厅左...
刚刚!智星菠萝透视,智星德州辅... 刚刚!智星菠萝透视,智星德州辅助译码插件靠谱吗,好像是有挂(的确有挂)进入游戏-大厅左侧-新手福利-...
教学辅助挂!wepokerh5... 教学辅助挂!wepokerh5破解,德普之星app安卓版破解版,都是确实有挂(有挂详情)1、许多玩家...