Completed 401 Unauthorized creation of user login after registration

I am working on redefining the registration controller, when I sign up with a new user, he signs me up for the first time, but when I log out and then try to log in, it gives me an error below in the console

Processing by Devise::SessionsController#create as HTML Parameters: {"utf8"=>"✓","authenticity_token"=>"Wq8QW/F8X1BVxFcH6M9WU8OUpIGjKI1mKd1+/OBGyGY=", "user"=> {"email"=>" jamil@gmail.com ", "password"=>"[FILTERED]", "remember_me"=>"0"}, "commit"=>"Sign in"} User Load (0.2ms) SELECT `users`.* FROM `users` WHERE `users`.`email` = ' jamil@gmail.com ' LIMIT 1 **Completed 401 Unauthorized in 16ms** Processing by Devise::SessionsController#new as HTML Parameters: {"utf8"=>"✓" , "authenticity_token"=>"Wq8QW/F8X1BVxFcH6M9WU8OUpIGjKI1mKd1+/OBGyGY=", "user"=> {"email"=>" jamil@gmail.com ", "password"=>"[FILTERED]", "remember_me"=>"0"}, "commit"=>"Sign in"} 

and then it issues an invalid email or password message

Please help me with this strange problem ... I was hanged.

Here is my registration form

 <h2>Sign up</h2> 
resource_name ,: url => registration_path (resource_name)) do | f | %>
  <div><%= f.label :email %><br /> <%= f.email_field :email, :autofocus => true %></div> <div><%= f.label :Connector_code %><br /> <%= f.text_field :invitation_token,:value => @token %></div> <div><%= f.label :password %><br /> <%= f.password_field :password %></div> <div><%= f.label :password_confirmation %><br /> <%= f.password_field :password_confirmation %></div> <div><%= f.label :Friends_code %><br /> <%= f.text_field :friend_token ,:value =>params[:invitation_token]%></div> <div><%= f.submit "Sign up" %></div> <% end %> <%= render "devise/shared/links" %> Thanks 
+4
source share
1 answer

Try setting the authentication_keys parameter explicitly either in the initialization file or in the model itself:

 # config/initializers/devise.rb Devise.setup do |config| config.authentication_keys = [ :email ] end 

or

 # app/models/user.rb class User < ActiveRecord::Base devise :database_authenticatable, :registerable, :recoverable, :rememberable, :trackable, :validatable, :authentication_keys => [:email] # Setup accessible (or protected) attributes for your model attr_accessible :email, :password, :password_confirmation, :remember_me end 
0
source

Source: https://habr.com/ru/post/1485984/


All Articles