devise sign up automatically signs in user

2019-08-01 10:35发布

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?

3条回答
放荡不羁爱自由
2楼-- · 2019-08-01 10:44

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

In your config/initializers/devise.rb:

config.allow_unconfirmed_access_for = 1.days
查看更多
SAY GOODBYE
3楼-- · 2019-08-01 10:51

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.

查看更多
虎瘦雄心在
4楼-- · 2019-08-01 11:02

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
查看更多
登录 后发表回答