2

I use devise in my rails application and I want like to know if it is possible to make a trick with registration form:

If a user types in a registration form his emai,l password and its confirmation and his email is already taken (because he forgot that is already registered, log in him (if pass is the correct) rather than show him a error message?

Of course if the password is not the same show the message like as usual.

I not found any article on this subject (or I'm wrong)

Does It sound possible or too strange?

Thanks for help

Reporter
  • 3,897
  • 5
  • 33
  • 47
  • strange. Show an error message saying that the email is already taken – usha Oct 17 '13 at 13:43
  • Not a bad UX idea to me, this is not worst that registering without password confirmation as we sometime see. – kik Oct 17 '13 at 14:20

1 Answers1

4

AFAIK, there is no builtin feature in devise to allow that.

But devise is customisable. What you could do is to override Devise::RegistrationsController, and use Devise::SessionsController#create-like code in case user already exists :

class RegistrationsController < Devise::RegistrationsController
  def create
    if <known_user_with_good_password>
      <sign_in>
    else
      super
    end
  end
end

You will have to dive a bit into warden to do it properly, though.

Check this answer about how to override a devise controller.

Community
  • 1
  • 1
kik
  • 7,867
  • 2
  • 31
  • 32