ruby on rails - active_for_authentication? not working -


i using active_for_authentication? allow active users login through devise. it's not working.

my controller:

class dashboarduserscontroller < applicationcontroller def active_for_authentication?   super && self.deactivated_ind end  def inactive_message   "sorry, account has been deactivated." end 

my model:

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 

my user table:

t.string   "deactivated_ind",      limit: 1 t.date     "deactivated_date" 

by using deactivated_ind y / n check user active / inactive. want allow devise log in user have n in deactivated_ind colomn

part of problem, i'm guessing you're using string "deactivated_ind" instead of boolean. string of "n" , string of "y" both true when try use them boolean values, since neither nil.


Comments

Popular posts from this blog

c++ - QTextObjectInterface with Qml TextEdit (QQuickTextEdit) -

javascript - angular ng-required radio button not toggling required off in firefox 33, OK in chrome -

xcode - Swift Playground - Files are not readable -