私は最近Deviseの仕事を得ました。新しいユーザーはサインインしてサインアップし、ログアウトします。しかし、古いユーザーには問題があります。私は、401が無許可になったところまで来ました。これは、サインイン時にハッシュが間違って作成されていて、正しくマッチングしていないように思えます。Rails CakePHPのレガシーユーザを
私のユーザモデル:
class User < ActiveRecord::Base
require "digest/sha1"
# Include default devise modules. Others available are:
# :token_authenticatable, :encryptable, :confirmable, :lockable, :timeoutable and :omniauthable
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validatable, :encryptable, :encryptor => :old_cakephp_auth
# Setup accessible (or protected) attributes for your model
attr_accessible :email, :password, :password_confirmation, :remember_me
has_many :events
end
は、CakePHPは、SHA1を使用していますが、私はそれが物事をどうするかの詳細を知りません。これは明らかにうまくいかないので、私はここにいるのです:
require "digest/sha1"
module Devise
module Encryptors
class OldCakephpAuth < Base
def self.digest(password, stretches, salt, pepper)
Digest::SHA1.hexdigest("#{salt}#{password}")
end
end
end
end
私はそれをカスタム暗号化の例を追加する方法から得ました。彼らはこれを持っていた:
Digest::SHA1.hexdigest("--#{salt}--#{password}--")
それはどちらもうまくいかなかった。誰にでもアイデアはありますか?
Digest :: SHA1.hexdigest( "#{salt}#{password}")実際にはDBにある暗号化された同じパスワードが返されますが、まだ401の権限のないメッセージが返されます。私はリターンDigest :: SHA1.hexdigest( "#{salt}#{password}")を試しましたが、それはどちらもしません。 – Parris