0

I have used restful-authentication and I have "public" layout and a completely different "members" layout. When someone visits my root (defaults to public) how can I check if they are logged in and redirect them to the member's section?

chrishomer
  • 4,900
  • 5
  • 38
  • 52

2 Answers2

3

RestfulAuthentication provides some conditional methods/helpers including one called logged_in?. It returns true if the user is logged in. Check out the authenticated_system.rb file for the list of all available methods.

Simone Carletti
  • 173,507
  • 49
  • 363
  • 364
1

You could define a method like this in application_controller.rb:

private
def require_user
  # logic to check if session exists and redirect if not
end

Then add the following in your pages that require that the user be logged in:

before_filter :require_user  

I'm not familiar with restful-auth so I don't know the exact check that would be required.

Good luck.

cakeforcerberus
  • 4,657
  • 6
  • 32
  • 42