如何在自定义会话控制器上确定用户是第一次登录,我希望能够创建会话并重定向到welcome#index
如果是第一次,否则它将被重定向到root_url
.
我的代码如下
class MysessionsController < Devise::SessionsController
def create
self.resource = warden.authenticate!(auth_options)
set_flash_message(:notice, :signed_in) if is_navigational_format?
sign_in(resource_name, resource)
respond_with resource, :location => after_sign_in_path_for(resource)
end
protected
def after_sign_up_path_for(resource)
"http://google.com"
end
end
我知道我需要定制after_sign_up_path_for(resource)
达到我想要的,但我找不到如何确定用户之前是否已使用设备登录
你应该能够做到这一点:sign_in_count
柱子。如果为 0 则表示用户之前没有登录过
举个例子
redirect_to ((current_user.sign_in_count == 0) ? path1 : path2 )
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)