1

I know I can make an user approved or not approved using devise, therefor an user won't be able to log in until an admin approves them.

I want an admin to be able to ban / unban users as well, which is different from approving since approving is an one way and one time process and I don't want to mix it up with banning. I sought out this functionality at devise's web site and didn't find anything valuable.

Is there any devise's way to do that?

Alan Coromano
  • 24,958
  • 53
  • 135
  • 205
  • I suggest add a boolean column to Users called 'banned' so an admin check the checkbox or click button when editing the user in the backend, and the boolean will return true. And then on session controller add authentication block for user banned to login. – rails_id Jul 02 '13 at 07:57
  • @anonymousxxx it figures, but I think there should be a standard way in Devise gem. – Alan Coromano Jul 02 '13 at 08:09
  • you can lock, unlock users,if that can solve your purpose. – Rubyman Jul 02 '13 at 08:15
  • @MariusKavansky so want you give to a user something like time of banned user? and authomatically unbanned user if time is over of banned? – rails_id Jul 02 '13 at 10:01
  • Possible duplicate of [Rails + Devise - Is there a way to BAN a user so they can't login or reset their password?](https://stackoverflow.com/questions/5629480/rails-devise-is-there-a-way-to-ban-a-user-so-they-cant-login-or-reset-their) – Mike B Apr 09 '19 at 08:22

1 Answers1

-2

Take a look at this Devise wiki page https://github.com/plataformatec/devise/wiki/How-To:-Require-admin-to-activate-account-before-sign_in

Should solve your problem.

Mike Szyndel
  • 10,461
  • 10
  • 47
  • 63
  • This question is about banning, not requiring admin to activate the account. – jonlink Feb 14 '17 at 16:02
  • @jonlink It is not but it's trivially easy to extend the solution from the link to support banning users. It's all about locking and unlocking. – Mike Szyndel Mar 31 '17 at 09:46