ruby on rails - Protect routes from users who are not signed in -
ruby on rails - Protect routes from users who are not signed in -
i'm using rails 4 , devise authenticate users. 1 time user logs in, redirected sinatra app. need route page protected unsigned-in users.
so route need prevent users visiting if not signed in /kibana
here routes files:
devise_for :user root 'pages#home' mount kibana::sinatra::web => '/kibana', :trailing_slash => true any help much appreciated, give thanks you.
edit here applicationcontroller file
protect_from_forgery before_filter :check_user private def check_user if request.fullpath =~ /kibana/ && !user_signed_in? authenticate :user end end end yet, not result need. when visit localhost:3000 redirects me user login note need logged in, when visit /kibana/ shows without having logged in.
more or less way:
class applicationcontroller before_filter :check_user private def check_user if !current_user && request.fullpath =~ /kibana/ redirect_to your_app_login_url end end end edit:
it looks wrong, within routes.rb:
authenticate :user mount kibana::sinatra::web => '/kibana', :trailing_slash => true end ruby-on-rails authentication ruby-on-rails-4 devise routes
Comments
Post a Comment