1

when i sign up a user, but don't have confirmable setup just yet (i.e. will be in the future but commented out for now), does it automatically sign in the user?

i need sign_up to just sign_up the user, but not sign him in, it needs to redirect to the login page, how do i get sign up to not log the user in?

newbie_86
  • 4,520
  • 17
  • 58
  • 89

3 Answers3

5

Instead of copy pasting code and replacing one line (which could be harder to maintain), just override the after_sign_up_path_for(resource), so it uses the after_sign_in_path_for(resource) instead:

def after_sign_up_path_for(resource)
    after_sign_in_path_for(resource)
end
Leonel Galán
  • 6,993
  • 2
  • 41
  • 60
  • Is it possible to have different paths depending on the request type ? (Html, JS, JSON, etc.) ? – Cyril Duchon-Doris Jun 19 '15 at 11:28
  • No need, devise's registration controller uses this path within `respond_with` (e.g. `respond_with resource, location: after_sign_up_path_for(resource)`, so that will take care of the request type for you. Devise should respond to JSON by default, I'm not sure about JS. – Leonel Galán Jun 22 '15 at 17:40
5

You need allow unconfirmed user to access at least one day.

In your config/initializers/devise.rb:

config.allow_unconfirmed_access_for = 1.days
monteirobrena
  • 2,562
  • 1
  • 33
  • 45
0

Override the RegistrationsController and then override the create action. Then replace this line in your new create action. Don't forget to use the rest of the code from the original create action.

Community
  • 1
  • 1
Zabba
  • 64,285
  • 47
  • 179
  • 207
  • if i enable confirmable, i'm assuming it won't automatically sign in the user until he's confirmed? is that correct? – newbie_86 Apr 09 '11 at 23:18
  • yes, then the login would occur when the user clicks on the confirmation link in the email – Zabba Apr 09 '11 at 23:25
  • 1
    Not necessarily, confirmable will allow the user to login if allow_unconfirmed_access_for is set. (See devise.rb) For example, you could: config.allow_unconfirmed_access_for = 1.days – Leonel Galán Feb 01 '13 at 17:19