2013-07-15 5 views
2

Devise 2.2.4와 함께 Rails 3.2.13을 설치했습니다. 기본 devise 설정 (config.mail_sender 제외)을 사용하고, erb에서 slim으로 변환 된 뷰를 변환했습니다. 이제 이상한 버그가 있습니다 : 사용자가 등록 할 수 있으며, 비밀번호를 복원 할 수 있지만 로그인 할 수 없습니다!Devise : 로그인 할 수 없습니다 (Unauthorized 401)

로그 :

Started POST "https://stackoverflow.com/users/sign_in" for 188.186.102.147 at 2013-07-14 17:58:42 +0400 
Processing by Devise::SessionsController#create as HTML 
    Parameters: {"utf8"=>"✓", "authenticity_token"=>"eqZ9zAUWn+blmhNMTi3iqhjX9ac1N8EaXpqNMyp/fYw=", "user"=>{"email"=>"[email protected]", "password"=>"[FILTERED]", "remember_me"=>"1"}, "commit"=>"Войти"} 
Completed 401 Unauthorized in 1ms 
Processing by Devise::SessionsController#new as HTML 
    Parameters: {"utf8"=>"✓", "authenticity_token"=>"eqZ9zAUWn+blmhNMTi3iqhjX9ac1N8EaXpqNMyp/fYw=", "user"=>{"email"=>"[email protected]", "password"=>"[FILTERED]", "remember_me"=>"1"}, "commit"=>"Войти"} 
    Rendered devise/shared/_links.slim (3.8ms) 
    Rendered devise/sessions/new.html.slim within layouts/application (59.6ms) 
Completed 200 OK in 208ms (Views: 83.6ms | ActiveRecord: 1.4ms) 

설정/초기화/devise.rb :

Devise.setup do |config| 
    config.mailer_sender = "[email protected]" 

    require 'devise/orm/active_record' 

    config.case_insensitive_keys = [ :email ] 
    config.strip_whitespace_keys = [ :email ] 
    config.skip_session_storage = [:http_auth] 
    config.stretches = Rails.env.test? ? 1 : 10 
    config.reconfirmable = true 
    config.password_length = 8..128 
    config.reset_password_within = 6.hours 
    config.sign_out_via = :delete 
end 

모델 : 사용자 테이블의

class User < ActiveRecord::Base 
    devise :database_authenticatable, :registerable, 
     :recoverable, :rememberable, :trackable, :validatable 

    attr_accessible :email, :password, :password_confirmation, :remember_me 
    devise :database_authenticatable, :registerable, 
     :recoverable, :trackable, :rememberable, :validatable 

    attr_accessible :email, :password, :password_confirmation, :remember_me 
end 

덤프 :

CREATE TABLE `users` (
    `id` int(11) NOT NULL AUTO_INCREMENT, 
    `email` varchar(255) COLLATE utf8_unicode_ci NOT NULL DEFAULT '', 
    `encrypted_password` varchar(255) COLLATE utf8_unicode_ci NOT NULL DEFAULT '', 
    `reset_password_token` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, 
    `reset_password_sent_at` datetime DEFAULT NULL, 
    `remember_created_at` datetime DEFAULT NULL, 
    `sign_in_count` int(11) DEFAULT '0', 
    `current_sign_in_at` datetime DEFAULT NULL, 
    `last_sign_in_at` datetime DEFAULT NULL, 
    `current_sign_in_ip` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, 
    `last_sign_in_ip` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, 
    `created_at` datetime NOT NULL, 
    `updated_at` datetime NOT NULL, 
    PRIMARY KEY (`id`), 
    UNIQUE KEY `index_users_on_email` (`email`), 
    UNIQUE KEY `index_users_on_reset_password_token` (`reset_password_token`) 
) ENGINE=MyISAM AUTO_INCREMENT=2 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; 

LOCK TABLES `users` WRITE; 
INSERT INTO `users` VALUES (1,'[email protected]','$2a$10$tLC/NVBIa3cyI0HkiaZ7O.oXKTZ/jVm/L8jDMsSQ27CzNWcefWkCm',NULL,NULL,NULL,2,'2013-07-14 15:49:29','2013-07-14 12:37:07','188.186.102.147','188.186.102.147','2013-07-14 12:37:07','2013-07-14 15:49:29'); 
UNLOCK TABLES; 

아무도 도와 줄 수 있습니까?

+0

401 오류는 대개 필요한 인증이 실패했거나 제공되지 않았 음을 나타냅니다. http://en.wikipedia.org/wiki/List_of_HTTP_status_codes – David

+0

잘못된 로그인 (전자 메일) 또는 암호를 입력했습니다. 작성한 사용자가 있습니까? 플래시 메시지가 뭐라 구요? –

+0

한 명의 사용자 (본인)가 있으며 정확한 로그인과 비밀번호를 사용합니다 (복사하여 붙여 넣기를 시도했습니다). 잘못된 사용자 이름 또는 암호에 대한 플래시 메시지가 표시되었습니다. – ertaquo

답변

-4

해결 : 레일즈 4를 Devise와 함께 설치했는데, 그런 문제는 없습니다.

+1

나는 레일즈 4를 가지고 있으며, 여전히이 이슈를 가지고있다. –

+0

이 질문에 대한 답을 제공하지 않습니다. 비평하거나 저자의 설명을 요청하려면 게시물 아래에 의견을 남기십시오. 자신의 게시물에 언제나 댓글을 달 수 있으며 충분한 [평판] (http://stackoverflow.com/help/whats-reputation)을 갖게되면 [모든 게시물에 댓글을 달 수] 있어야합니다 (http://stackoverflow.com/help/privileges/comment). - [리뷰에서] (리뷰/저품절 포스트/11473726) – TheGeorgeous

+0

@TheGeorgeous Mind가 내게 어떻게 답변을 제공하지 않는지 설명해 주시겠습니까? – Undo

7

좋아, 그럼이 문제를 해결했습니다. 내 실수도 처음부터 있었어. 몇 가지

<p class="notice"><%= notice %></p> 
<p class="alert"><%= alert %></p> 

내 로그인 양식을 만들려고 할 때 레이아웃의 내 세션/새로운보기에서이 줄을 제거했습니다. 따라서 앱을 설치할 때 rake 작업에서 관리자와 암호를 삽입 할 때 계정이 확인되지 않았거나 암호, 사용자 이름이 잘못되었다는 표시가 나타나지 않았습니다.

내가이 줄을 추가하면 solution found here 덕분에 나는 피 묻은 멍청이이기 때문에 잘못된 전자 메일 주소를 사용하고 있음을 알 수있었습니다.

관련 문제