active_for_authentication을 사용하고 있습니까? 활성 사용자 만이 장치를 통해 로그인 할 수 있습니다. 하지만 작동하지 않습니다.active_for_authentication? 작동하지 않음
내 컨트롤러 :
class DashboardUsersController < ApplicationController
def active_for_authentication?
super && self.deactivated_ind
end
def inactive_message
"Sorry, this account has been deactivated."
end
내 모델 :
class DashboardUser < ActiveRecord::Base
devise :database_authenticatable,:rememberable, :trackable, :validatable, :timeoutable
attr_accessor :login
def self.find_first_by_auth_conditions(warden_conditions)
conditions = warden_conditions.dup
if login = conditions.delete(:login)
where(conditions).where(["username = :value OR lower(email) = lower(:value)", { :value => login }]).first
else
where(conditions).first
end
end
end
내 사용자 테이블 :
t.string "deactivated_ind", limit: 1
t.date "deactivated_date"
Y를 deactivated_ind 사용하여/N 나 사용자가 비활성/활성화 확인. 이제는 사용자가 deactivated_ind colomn에 N이있는 사용자 만 로그인 할 수있게하려고합니다.
나는 보통 'private'라고 쓰지만,'active_for_authentication' (그리고 그것의 동반자'inactive_message' meth)과 같은 모든 Devise 콜백 메소드를 덮어 씁니다. od)는 '공개'인 것처럼 보입니다. –