You can do it by comparing the current_user method result with nil.
current_user
nil
See also:
How to show the «Log In» popup programmatically?