Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3986270
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T05:59:29+00:00 2026-05-20T05:59:29+00:00

I use Devise for authentication and I have an admin role who can manage

  • 0

I use Devise for authentication and I have an admin role who can manage users.

Apart from this the admin can also lock a user preventing him from logging in the future. I have created a Boolean field inside ‘User’ model called ‘is_locked?’. When the admin locks a user this boolean field is set to true. Based on this info I can know if a user is locked or not.

Now when user tries to log in, before setting up his session, I have to check this logic. I’m clueless about where to add this logic. Or this any custom methods or events which devise provides, so that I can add it there.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T05:59:30+00:00Added an answer on May 20, 2026 at 5:59 am

    I’ve found that you can stack before_filters in the controller, so if you wanted to check for an authenticate_user!, you could also use a before_filter (after authenticate_user!) to check for a locked user. If the user model has a boolean attribute locked, you can simply write a private method in your controller (or helper) like this:

    #top of controller
    before_filter authenticate_user!
    before_filter user_active!
    
    #bottom of controller
    private
    def user_active!
      unless current_user.locked?
        return true
      end
      redirect_to root_url, :notice => "Your account is locked."
      return false
    end
    

    This will give you the page you want if you’re an unlocked user, and redirect you to the root page with an error message if the user is locked.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two models User and Admin(with RailsAdmin) that use Devise. I sign in
Using Resque and Devise, i have roles for User, like: User.first.role #=> admin User.last.role
I have a Rails application for which I use devise to authenticate my users
I'm using rails_admin which use devise. Some words still displays in english. I have
I use the devise's authenticate_user! method in a controller. This is working fine when
I have a rails application, and I authenticate users to the application using Devise.
I have the following issue. I'm using devise as an authentication module for my
I am definitely going to use an authentication scheme (Devise) with 3 roles: user,
I have a Rails 3 app with authentication setup using Devise with the registerable
I'm using the devise authentication plugin under rails 3. At the moment, I have

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.