这是非常奇怪的类型错误我有用户并想通过设计登录,但我面临奇怪的错误。我成功注册但是当我尝试登录时,这里的无效电子邮件或密码错误可能是一些代码。
class ApplicationController < ActionController::Base
before_filter :update_sanitized_params, if: :devise_controller?
protected
def update_sanitized_params
devise_parameter_sanitizer.for(:sign_up) {|u| u.permit(:email, :password, :password_confirmation, :role)}
devise_parameter_sanitizer.for(:sign_in) { |u| u.permit(:email, :password) }
end
end
我的表单是
<h2>Sign in</h2>
<%= form_for(resource, :as => resource_name, :url => user_session_path(resource_name)) do |f| %>
<div><%= f.label :email %><br />
<%= f.email_field :email, :autofocus => true %></div>
<div><%= f.label :password %><br />
<%= f.password_field :password %></div>
<% if devise_mapping.rememberable? -%>
<div><%= f.check_box :remember_me %> <%= f.label :remember_me %></div>
<% end -%>
<div><%= f.submit "Sign in" %></div>
<% end %>
<%= render "devise/shared/links" %>
和我的devise.rb有以下内容
config.authentication_keys = [ :email ]
config.case_insensitive_keys = [ :email ]
config.strip_whitespace_keys = [ :email ]
config.reconfirmable = true
config.password_length = 8..128
config.reset_password_within = 6.hours
config.sign_out_via = :delete
这是log
Started POST "/users/sign_in.user" for 127.0.0.1 at 2014-02-11 10:52:50 +0500
Processing by Devise::SessionsController#create as
Parameters: {"utf8"=>"✓", "authenticity_token"=>"SRARjzpSBMAck6qAOXHj4f4ycjYXX/1tYWoVrDhhylA=", "user"=>{"email"=>"asnad321@gmail.com", "password"=>"[FILTERED]", "remember_me"=>"0"}, "commit"=>"Sign in"}
User Load (0.2ms) SELECT `users`.* FROM `users` WHERE `users`.`email` = 'asnad321@gmail.com' ORDER BY `users`.`id` ASC LIMIT 1
Completed 401 Unauthorized in 77ms
答案 0 :(得分:0)
我已经解决了这个问题。问题是加密密码有一个保存回调加密密码但设计已经有功能,所以密码加密两次。谢谢大家的帮助。