开发者

Devise showing error 'invalid email or password' upon going to login

开发者 https://www.devze.com 2023-02-08 15:26 出处:网络
I\'m using Rails 3 with Devise and have setup my routes.rb file like so: devise_for :users, :path_names => { :sign_in => \'login\', :sign_out => \'logout\'}

I'm using Rails 3 with Devise and have setup my routes.rb file like so:

  devise_for :users,
  :path_names => { :sign_in => 'login', :sign_out => 'logout'}

  devise_scope :user do
    get '/login' => 'devise/sessions#create'
    get '/logout' => 'devise/sessions#destroy'
  end

  resources :users

When I go to /login I get the flash messages:

Signed out successfully.
Invalid email or password.

The first message is a notice and I'm not worried about it, but the second one is an alert and is annoying as the user hasn't开发者_StackOverflow社区 hit sign in yet and it's already complaining that there is no password.

Is there an easy way to suppress this message? Have I setup devise wrong maybe.

I'm using username field to login instead of email.

I have changed my devise.rb to have

  config.authentication_keys = [ :username ]


This was an easy mistake when I look back at it with a fresh head:

This

get '/login' => 'devise/sessions#create'

Should be

get '/login' => 'devise/sessions#new'
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号