2009-09-25 88 views
2

我正在嘗試實施Authlogic。註冊是好的,它進入所有必要的細節到我的數據庫..Ruby on Rails Authlogic密碼無效

..但是當我嘗試登錄,它給我的錯誤:

1 error prohibited this user session from being saved

There were problems with the following fields:

Password is not valid

我的密碼有效。我不確定發生了什麼事。有任何想法嗎?

+1

這聽起來很熟悉,但我的記憶沒有震動......也許你可以發佈你的遷移和控制器/模型/視圖登錄? – SingleShot 2009-09-25 02:40:11

+0

我第二次SingleShot的聲明。 – khelll 2009-09-25 04:12:14

+0

是什麼讓你確定你的密碼是有效的?顯然不是。也就是說,一些驗證是添加錯誤。例如,您是否知道authlogic中的內置默認驗證? – 2009-09-25 10:22:40

回答

4

我有同樣的問題,那是因爲我是從寧靜的驗證遷移。 問題是: Restful認證將40個字符的上限放在密碼鹽和密碼密碼上。 由authlogic生成的哈希大於那個。

class RemovePasswordSaltCap < ActiveRecord::Migration 
    def self.up 
    change_column :users, :password_salt, :string, :limit => nil 
    change_column :users, :crypted_password, :string, :limit => nil 
    end 
end 

在罰款手冊中找到了這個答案。

the fine manual

+0

美麗!我掙扎了好幾個小時!謝謝 :) – Gazza 2010-07-15 12:27:19

1

在你的用戶模型,試試這個:

class User < ActiveRecord::Base 

    acts_as_authentic do |c| 
    c.validate_password_field = false 
    end 

end 

然後再次嘗試登錄。如果這有效,那麼你會知道authlogic的默認驗證會讓你失望。

您也可以嘗試

valid_password?(attempted_password, check_against_database = check_passwords_against_database?) 

與控制檯

0

我得到了同樣的錯誤,我的問題是,我沒有用,我以前用寧靜的身份驗證使用的REST_AUTH_SITE_KEY鍵值。

我添加鍵值,一切工作:)

0

如果升級到authlogic默認crypto_provider已從Sha512變更爲SCrypt所以它可能是密碼被破的情況下。看看authlogic readme