简体   繁体   English

设计中的电子邮件或密码无效

[英]invalid email or password in devise

It is very strange type error I have user and want to sign in through devise but I am facing strange error.这是非常奇怪的类型错误,我有用户并想通过设备登录,但我遇到了奇怪的错误。 I sign up successfully but when I try to login it through and error of invalid email or password here is may some code.我注册成功,但是当我尝试登录时,错误的电子邮件或密码无效,这可能是一些代码。

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

My form is我的表格是

<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" %>

and my devise.rb has following contents我的 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

here is 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

I have resolve the problem.我已经解决了这个问题。 The problem was with encrypt password there was a before save call back which encrypts the password but devise already have feature so password was encrypted twice.问题是加密密码有一个保存前的回调,它加密密码,但设计已经有功能,所以密码被加密了两次。 Thanks guys for help.谢谢大家的帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM