disabling user accounts

46 views
Skip to first unread message

fugee ohu

unread,
Sep 14, 2017, 8:25:43 AM9/14/17
to Ruby on Rails: Talk
Does devise provide an already built in method for disabling user accounts so I can disable accounts without any additional coding

nynhex

unread,
Sep 14, 2017, 8:48:35 AM9/14/17
to rubyonra...@googlegroups.com
Not built in, but you could easily write your own method to prevent an account from logging in.  Simply throw a Boolean of active: true/false and write a method to activate/deactivate the account.  Then in your application controller have a method that checks the status of an account and if it does not meet the active true state then force it to logout and send a flash message “Your account has been disabled”.  If you google, there a lot of examples on this.


On Sep 14, 2017, at 7:25 AM, fugee ohu <fuge...@gmail.com> wrote:

Does devise provide an already built in method for disabling user accounts so I can disable accounts without any additional coding

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-ta...@googlegroups.com.
To post to this group, send email to rubyonra...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/d634151a-6044-4b09-b770-8feacc4ab222%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

fugee ohu

unread,
Sep 14, 2017, 5:18:25 PM9/14/17
to Ruby on Rails: Talk
Force it to log out with redirect to <action> ?

nynhex

unread,
Sep 15, 2017, 8:16:11 AM9/15/17
to rubyonra...@googlegroups.com
Force it to logout with the standard devise logout method.


Hassan Schroeder

unread,
Sep 15, 2017, 8:29:55 AM9/15/17
to rubyonrails-talk
On Thu, Sep 14, 2017 at 5:25 AM, fugee ohu <fuge...@gmail.com> wrote:
> Does devise provide an already built in method for disabling user accounts
> so I can disable accounts without any additional coding

Read the documentation for :lockable

That said, how exactly do you intend to "disable accounts"? From
a console, through a form? You will have to do *some* coding to
accomodate whatever approach(es) you choose.

--
Hassan Schroeder ------------------------ hassan.s...@gmail.com
twitter: @hassan
Consulting Availability : Silicon Valley or remote

Ben Edwards

unread,
Sep 15, 2017, 4:50:29 PM9/15/17
to Ruby on Rails: Talk
LOL, I just read the original message.  'without any additional coding' seems to indicate the OP probably should not be using rails, with it being an application framework rather than a drag and drop site builder.

Ben Edwards

unread,
Sep 15, 2017, 4:52:19 PM9/15/17
to Ruby on Rails: Talk
Saying that you could probably lock the account perminately  with some cleaver setup and a bit of SQL, which is almost not coding.

Hassan Schroeder

unread,
Sep 15, 2017, 5:14:19 PM9/15/17
to rubyonrails-talk
On Fri, Sep 15, 2017 at 1:52 PM, Ben Edwards <lo...@funkytwig.com> wrote:
> Saying that you could probably lock the account perminately with some
> cleaver setup and a bit of SQL, which is almost not coding.

If you enabled the :lockable feature, all you'd have to do would be
to "log in" with a bad password N times (whatever you've config'd)
and boom, user locked out.

I'd personally prefer to write a simple admin method, but...
Reply all
Reply to author
Forward
0 new messages