【问题标题】:Warden authentication recalls 401 UnauthorizedWarden 认证召回 401 Unauthorized
【发布时间】:2012-07-13 02:51:53
【问题描述】:

我尝试使用全新的 Rails 应用程序设置设计,我已经使用 gemfile 和捆绑安装正确安装了设计

按照使用 rails 安装的设计生成 devise:install

使用 rails generate devise user 创建了一个新模型

rake db:migrate 创建用户表

添加了devise_for :users do get 'users/sign_out', :to => 'devise/sessions#destroy' end 以使用我的浏览器退出

运行 Rails 服务器

去 localhost:3000/users/sign_up 创建一个新用户

转到 localhost:3000/users/sign_out 将他注销

转到 localhost:3000/users/sign_in 并尝试再次登录他并失败并显示以下内容并将我发送回登录屏幕而不登录

Started POST "/users/sign_in" for 127.0.0.1 at 2012-07-13 16:55:28 +0800
  Processing by Devise::SessionsController#create as HTML
  Parameters: {"utf8"=>"✓", "authenticity_token"=>"cbFEP0FJ/e2XYHfub3ZeI7nEX0nCheXzCDs2ner3Zw8=", "newuser"=>{"email"=>"henghong.lee@gmail.com", "password"=>"[FILTERED]", "remember_me"=>"0"}, "commit"=>"Sign in"}
Completed 401 Unauthorized in 1ms
  Processing by Devise::SessionsController#new as HTML
  Parameters: {"utf8"=>"✓", "authenticity_token"=>"cbFEP0FJ/e2XYHfub3ZeI7nEX0nCheXzCDs2ner3Zw8=", "newuser"=>{"email"=>"henghong.lee@gmail.com", "password"=>"[FILTERED]", "remember_me"=>"0"}, "commit"=>"Sign in"}
Rendered /Users/Kinnovate/.rvm/gems/ruby-1.9.3-p194/gems/devise-2.1.2/app/views/devise/shared/_links.erb (1.0ms)
Rendered /Users/Kinnovate/.rvm/gems/ruby-1.9.3-p194/gems/devise-2.1.2/app/views/devise/sessions/new.html.erb within layouts/application (4.9ms)
Completed 200 OK in 175ms (Views: 16.5ms | ActiveRecord: 1.3ms)

如何修复 Completed 401 Unauthorized ?

【问题讨论】:

    标签: ruby-on-rails authentication devise


    【解决方案1】:
    attr_accessor :password 
    

    似乎是问题的原因,因为该设计似乎没有为模型创建加密密码

    【讨论】:

    • 那么您究竟是如何解决这个问题的?
    • 我的问题原来出在 RefineryCMS 上——我需要一个单独的模型,它使用用户成员资格的设计。问题是我必须在 config/devise.rb 中包含 config.authentication_keys = [ :email ],因为 Refinery 覆盖了它,现在一切对我来说都很好。
    猜你喜欢
    • 2015-03-13
    • 2021-09-02
    • 1970-01-01
    • 2014-04-06
    • 2021-10-19
    • 2013-04-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多