使用rails 4设计auth失败

时间:2014-02-05 00:40:33

标签: ruby-on-rails ruby devise

在设计初始化程序中配置了pepper和secret_key。当我尝试登录时,我仍然在登录页面上。当我注册时,用户仍然在db中,但是没有登录。我已经尝试编写自定义控制器,当我放置sign_in(:user,User.first)时 - 没有意义。用户无法进行身份验证。

任何想法为什么?

1 个答案:

答案 0 :(得分:0)

我会尝试给你一些一般的答案,你可以说它是否好,无论如何它们只是可能的答案。

您是否尝试使用rails控制台登录?在此登录期间,您是否在日志中看到了错误?

这是我能够做到的一种方式:

>> ApplicationController.allow_forgery_protection = false
>> app.post('/sign_in', {"user"=>{"login"=>"login", "password"=>"password"}})

然后你可以这样做:

 >> app.get '/some_other_path_that_only_works_if_logged_in'
 >> pp app.response.body

如果登录失败,其他想法是重定向特定页面:

https://github.com/plataformatec/devise/wiki/How-To:-Redirect-to-a-specific-page-when-the-user-can-not-be-authenticated