How to programmatucally check in a Rails controller whether the current Discourse user is authenticated?

You can do it by comparing the current_user method result with nil.

An example

The method’s implementation

See also:

How to show the «Log In» popup programmatically?