devise sign up automatically signs in user

情到浓时终转凉″ 提交于 2019-12-11 07:29:14

问题


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?


回答1:


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



回答2:


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

In your config/initializers/devise.rb:

config.allow_unconfirmed_access_for = 1.days



回答3:


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.



来源:https://stackoverflow.com/questions/5608547/devise-sign-up-automatically-signs-in-user

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!