mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
Redirect all controllers to login if required
We want to skip the filter for sessions controller so that we can login and we want to skip the filter for static pages because those should be visible to visitors.
This commit is contained in:
@@ -22,6 +22,7 @@ class ApplicationController < ActionController::Base
|
||||
before_filter :preload_json
|
||||
before_filter :check_xhr
|
||||
before_filter :set_locale
|
||||
before_filter :redirect_to_login_if_required
|
||||
|
||||
rescue_from Exception do |exception|
|
||||
unless [ ActiveRecord::RecordNotFound, ActionController::RoutingError,
|
||||
@@ -280,6 +281,10 @@ class ApplicationController < ActionController::Base
|
||||
raise Discourse::NotLoggedIn.new unless current_user.present?
|
||||
end
|
||||
|
||||
def redirect_to_login_if_required
|
||||
redirect_to :login if SiteSetting.login_required? && !current_user
|
||||
end
|
||||
|
||||
def render_not_found_page(status=404)
|
||||
f = Topic.where(deleted_at: nil, archetype: "regular")
|
||||
@latest = f.order('views desc').take(10)
|
||||
|
||||
Reference in New Issue
Block a user