从宁静的身份验证迁移到设计 [英] Migrating from Restful Authentication to Devise

查看:81
本文介绍了从宁静的身份验证迁移到设计的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

一个数的Rails 2.3应用程序使用的是宁静的认证,但该插件似乎有使用Rails 3的一些问题,在升级到Rails我一直在使用设计3。有什么办法能顺利从宁静的认证过渡到设计?有没有人做了迁移,说明如何更新用户模式?

A number of Rails 2.3 apps are using Restful Authentication but that plugin seems to have some issues with Rails 3. In upgrading to Rails 3 I have been using Devise. Is there any way to smoothly transition from Restful Authentication to Devise? Has anyone done a migration that shows how to update the User model?

推荐答案

我更新从宁静的验证我的应用程序已经制定。这里是我的移民:

I updated my application from Restful Authentication to Devise already. Here is my migration:

class AlterUsersForDevise < ActiveRecord::Migration
  def self.up
    remove_column :users, :name
    change_column :users, :email, :string, :default => "", :null => false, :limit => 128
    rename_column :users, :crypted_password, :encrypted_password
    change_column :users, :encrypted_password, :string, :limit => 128, :default => "", :null => false
    rename_column :users, :salt, :password_salt
    change_column :users, :password_salt, :string, :default => "", :null => false, :limit => 255
    add_column :users, :reset_password_token, :string
    change_column :users, :remember_token, :string, :limit => 255
    rename_column :users, :remember_token_expires_at, :remember_created_at

    add_column :users, :sign_in_count, :integer, :default => 0
    add_column :users, :current_sign_in_at, :datetime
    add_column :users, :last_sign_in_at, :datetime
    add_column :users, :current_sign_in_ip, :string
    add_column :users, :last_sign_in_ip, :string

    rename_column :users, :activation_code, :confirmation_token
    change_column :users, :confirmation_token, :string, :limit => 255
    rename_column :users, :activated_at, :confirmed_at

    add_column :users, :confirmation_sent_at, :datetime
  end

  def self.down
    add_column :users, :name, :string, :limit => 100, :default => ""
    rename_column :users, :encrypted_password, :crypted_password
    change_column :users, :crypted_password, :string, :limit => 40
    rename_column :users, :password_salt, :salt
    change_column :users, :salt, :string, :limit => 40
    remove_column :users, :reset_password_token
    change_column :users, :remember_token, :string, :limit => 40
    rename_column :users, :remember_created_at, :remember_token_expires_at

    remove_column :users, :sign_in_count
    remove_column :users, :current_sign_in_at
    remove_column :users, :last_sign_in_at
    remove_column :users, :current_sign_in_ip
    remove_column :users, :last_sign_in_ip

    rename_column :users, :confirmation_token, :activation_code
    change_column :users, :confirmation_token, :string, :limit => 40
    rename_column :users, :confirmed_at, :activated_at

    remove_column :users, :confirmation_sent_at
  end
end

我的应用程序是不是至今居住。所以我用密码加密,从设计,而不是从宁静的授权之一。如果你的应用程序已经是活着的,你有活跃用户,你应该配置设计为使用SHA1从宁静的身份验证恩和解密密码。否则,所有用户必须申请一个新的密码。

My application isn't live so far. So i use the password encryption from Devise instead the one from Restful Authorization. If you application is already alive, and you have active users you should configure Devise to use SHA1 from Restful Authentication to en- and decrypt passwords. Otherwise all your users must request a new password.

您可以在色器件初始化配置此。

You can configure this in the devise initializer.

希望帮助...

这篇关于从宁静的身份验证迁移到设计的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆