나는 GET을 통해 로그 아웃 고안 인증을했다,하지만이 Angular.js 코드를 사용하여 로그 아웃 만들 수 없습니다 :이 Angular.js
이$scope.logout = ->
$http.get('/users/sign_out').success ->
#If it does not redirect from 'editor' to 'login' then you haven't actually logged out
$location.path('editor')
고안의 로그 아웃 동작은 것을 무작위로 - 가끔 로그 아웃하거나 때로는 로그 아웃하지 마십시오. 그리고 브라우저 주소창에 /users/sign_out
을 입력하면 항상 로그 아웃됩니다. 좋아
, 나는 Angular.js 다음 코드 캐싱 문제를 제거하는 요청을 게시 할 수 고안 인증의 로그를 전환하여 사용 :
$scope.logout = ->
$http.post('/users/sign_out').success ->
$location.path('editor')
이 좋은, 언제나처럼,하지만 로그 아웃 처음 로그 아웃 할 수 없었습니다. ,
match '/logout' => 'api#logout', :via => :post
class ApiController < ApplicationController
before_filter :authenticate_user!
def logout
sign_out
if current_user
puts 'Has not signed out!'
else
puts 'Has signed out!'
end
head :ok
end
end
및 sign_out
후 current_user
항상 전무는 것을 발견,하지만 약간의 기적에 의해 각 응용 프로그램은 ApiController의 다른 방법에 액세스 할 수 관리 :
나는 내 자신의 방법이 어떻게되는지하기로 결정 current_user는 거기에 nil이 아닙니다!
나는 그것을 이해하지 못한다. 좋습니다, 다른 HTTP 요청을 따르거나, 로그 아웃 요청 직후에 (또는 동시에) 인증 쿠키와 Devise 재 로그인을 전달할 수도 있지만 은 쿠키에서 전달 된 세션 ID가 만료되지 않아야합니다. sign_out 메서드 호출 직후에?!
당신은 sign_out [route a : devise.rb에서 경로를 가져 왔습니까?] (http://stackoverflow.com/questions/6557311/no-route-matches-users-sign-out-devise-rails-3)를 만들었습니까?) – shicholas
@shicholas : 물론 – Paul
레일 쿠키 또는 ng 쿠키는 어떻습니까? – shicholas