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 9011313
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T02:41:48+00:00 2026-06-16T02:41:48+00:00

I have a Ruby On Rails 3.x application using device. My goal is to

  • 0

I have a Ruby On Rails 3.x application using device.

My goal is to add a Yubikey input field to the login screen.

I have generated the views, adjusted the screen (i.e. the extra field shows up) and updated the routes as follows:

  devise_for :users, :controllers => { :sessions=>"sessions", :registrations => "registrations" }, :path => "users", :path_names => { :sign_in => "login", :sign_out => "logout", :sign_up => "register" }  

Not to forget, I created a session controller:

class SessionsController < Devise::SessionsController
  def create
    begin
      if do_some_other_checks
        super
      else
        build_resource
        clean_up_passwords(resource)
        flash[:alert] = "Login error"
        render :new
      end
    rescue => e
        build_resource
        clean_up_passwords(resource)
        flash[:alert] = "Login error"
        render :new
    end
  end
end

Unfortunately the code doesn’t quite work, it gets called after Devise has the user logged on, i.e. even if the additional check fails, the user still gets logged in.

  • 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-06-16T02:41:49+00:00Added an answer on June 16, 2026 at 2:41 am

    There is a simple way to do this in your user model by adding in the following, no need to create any devise controllers or change default routes …

    class User < ActiveRecord::Base
    
     # check to see if a user is active or not and deny login if not
     def active_for_authentication?
       super && do_some_other_checks
     end
    
    end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Ruby on Rails application that is using HAML based template views.
I have created a blog application using Ruby on Rails which includes the ability
I have built a very simple blog application using Ruby on Rails. New to
I have a Rails 3.2.2 application using Ruby version 1.9.2. I have created basic
I have installed Ruby On Rails Application on my harddrive, and i am using
I have built a blog application using Ruby on Rails. In the application I
I have created a blog application using Ruby on Rails and have just added
I have a Ruby Rails application using Resque. The Resuqe daemon crashes after running
I have a problem running a Ruby on Rails application using Passenger. My application
Have just finished my first web based application using Ruby on Rails. It was

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.