title: user.valid_password of devise gem does not work
body: <pre><code>def create
  user_password = params[:session][:password]
  user_email = params[:session][:email]
  user = user_email.present? &amp;&amp; User.find_by(email: user_email)
  
  if user and user.valid_password? user_password
    sign_in user
    user.generate_authentication_token!
    user.save
    render json: user, status: 200, location: [:api, user]
  
  else
    #render json: { errors: "Invalid email or passwords"}, status: 422
    render json: { errors: "Invalid email or passwords"}, status: 422
  
  end
  </code></pre>
  
  <p>end</p>
  
  <p>not able to login after user has signed in,it seems the valid_password? method does not encrypt the password in same format as encrypted password stored in database by the devise,any help would be appreciated.</p>