Devise - authentication scope setting

I use devise for authentication. How can I set the login area? For example, let's say I only want to authenticate the user for the realm:

User.where(:active => true)

I got it? It is simple, but if necessary I can develop more.

(I understand that there is a blockable module, but my real area is not for active users, it is more like current_site.users, where current_site is based on a domain)

+3
source share
2 answers

You can use default_scope ... but this may interfere with you.

Why not override the method find_for_database_authentication? See wiki .

+1
source

User, , :

# Called by Devise to see if an user can currently be signed in
def active_for_authentication?
  active? && super
end

# Called by Devise to get the proper error message when an user cannot be signed in
def inactive_message
  !active? ? :deactivated : super
end

devise.en.yml :

devise:
  failure:
    deactivated: "Luke, I'm your father and your account was locked!"
+14

All Articles