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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T22:20:52+00:00 2026-06-13T22:20:52+00:00

I would like to show my login page with error message like The system

  • 0

I would like to show my login page with error message like “The system cannot log you on at this time. Please try again later” when there is ldap error during the login process.

Currently, I have used the custom_failure.rb approach as described in
https://github.com/plataformatec/devise/wiki/How-To:-Redirect-to-a-specific-page-when-the-user-can-not-be-authenticated
and it is able to catch error like invalid username / password and I have redirected it to the login page
showing the error messages as desired without problem.
But this approach cannot catch the ldap errors.

These ldap errors are shown as a very raw html page like the following:

Errno::ETIMEDOUT in Devise::SessionsController#create

A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. – connect(2)

Rails.root: C:/extratxt/2.2.0/source/ruby/messaging
Application Trace | Framework Trace | Full Trace

Request

Parameters:

{"utf8"=>"✓",
 "user"=>{"username"=>"administrator",
 "password"=>"[FILTERED]",
 "remember_me"=>"0"},
 "commit"=>"Sign in"}

Show session dump

Show env dump
Response

Headers:

None

How can I prevent this and instead show my specified page (e.g. login page with my own error message) ?
Any idea ? Thanks

  • 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-13T22:20:53+00:00Added an answer on June 13, 2026 at 10:20 pm

    One way is to override the create session action, but there are a couple steps required to get it working. First, copy the devise views (if you haven’t already done so) with

    rails g devise:views
    

    Then you need to create a sessions_controller.rb file that extends Devise::SessionsController:

    # /app/controllers/sessions_controller.rb
    class SessionsController < Devise::SessionsController
    
      # copied from [...]/gems/devise-1.4.5/app/controllers/sessions_controller.rb
      # To find the path to your gem, use 'bundle show devise' 
      def create
    
        begin
          resource = warden.authenticate!(:scope => resource_name, :recall => "#{controller_path}#new")
          set_flash_message(:notice, :signed_in) if is_navigational_format?
          sign_in(resource_name, resource)
          respond_with resource, :location => redirect_location(resource_name, resource)
        rescue Net::LDAP::LdapError
          # handle your error
          respond_to do |format|
            format.html { redirect_to new_user_session_path, :notice => $!.to_s }
            format.json { render json: $!.to_s }
          end
        end
    
      end
    end
    

    Finally, in your config/routes.rb, you need to tell devise to use your customized controller:

    devise_for :users, :controllers => { :sessions => :sessions }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a login page that I would like to show in https. After
I'm using jQuery mobile with PhoneGap, and would like to show a login page
I would like to show the system form name into the caption of the
Thanks. I would like to let user login , And i try to do
I would like my server side PHP validation on a log in page to
I would like to show the value of a variable in a TextView, like
I would like to show and hide a div during hover and hover out.
I would like to show a div based on the Onclick event of an
I would like to show divs at a specific interval (10 seconds) and show
I would like to show different tabs in the top navigation of a SharePoint

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.