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

相关内容

热门资讯

透视讲解!多乐游戏脚本,ste... 【亲,多乐游戏脚本 这款游戏可以开挂的,确实是有挂的,很多玩家在这款多乐游戏脚本中打牌都会发现很多用...
必备辅助推荐!小程序河北微乐脚... 小程序河北微乐脚本 无需打开直接搜索微信:136704302本司针对手游进行,选择我们的四大理由: ...
发现一款"赣牌圈挂怎... 发现一款"赣牌圈挂怎么用"开挂(透视)辅助神器(原来确实是有挂的)-哔哩哔哩;1、超多福利:超高返利...
透视规律"爱玩联盟辅... 透视规律"爱玩联盟辅助软件视频讲解"开挂(透视)辅助工具(其实是有挂)-哔哩哔哩;爱玩联盟辅助软件视...
最新技巧!九酷众游辅助,小旋风... 最新技巧!九酷众游辅助,小旋风辅助器,切实教程(有人有挂)-哔哩哔哩 了解更多开挂安装加(13670...
透视透视"椰子乐动软... 透视透视"椰子乐动软件辅助"开挂(透视)辅助工具(果然真的有挂的)-哔哩哔哩,椰子乐动软件辅助是用手...
科普分享!江西上饶辅助器,杭州... 科普分享!江西上饶辅助器,杭州都莱辅助软件有没有用,2026新版教程(有挂辅助)-哔哩哔哩您好:杭州...
2024教程"云麻圈... 2024教程"云麻圈修改器"开挂(透视)辅助平台(果然确实有挂)-哔哩哔哩;最新版2026是一款经典...
透视科技!皮皮辅助软件,凑一桌... 皮皮辅助软件 无需打开直接搜索微信:136704302本司针对手游进行,选择我们的四大理由: 1、软...
1.9分钟了解"指尖... 1.9分钟了解"指尖四川刷无限钻石"开挂(透视)辅助插件(一直真的有挂)-哔哩哔哩;1、不需要AI权...