How can I determine on my custom session controller that the user is the first time login, I want to be able to create a session and to redirect to welcome#index
if its the first time else it would be redirected to root_url
.
The code that I have is has follow
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
I know I need to custom after_sign_up_path_for(resource)
to what I want but I cant find how to determine if the user has sign in before or not with devise
you should be able to do this with :sign_in_count
column. if this is 0 it means user has not sign in before
So as an example
redirect_to ((current_user.sign_in_count == 0) ? path1 : path2 )
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.