From 334a357363046db9bbc652a2024513a89518f419 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sigur=C3=B0ur=20Gu=C3=B0brandsson?= <sigurdur@sigginet.info> Date: Mon, 23 Feb 2015 21:20:36 +0000 Subject: [PATCH] FIX: Forward to SSO login automatically Forward to SSO login URL automatically if SSO is enabled and login is required. Makes it simpler for users to log in automatically. --- app/controllers/application_controller.rb | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index ddbc9b3d5..ced1ed88d 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -389,7 +389,13 @@ class ApplicationController < ActionController::Base # save original URL in a cookie cookies[:destination_url] = request.original_url unless request.original_url =~ /uploads/ - redirect_to :login if SiteSetting.login_required? + + # redirect user to the SSO page if we need to log in AND SSO is enabled + if (SiteSetting.enable_sso && SiteSetting.login_required) + redirect_to '/session/sso' + elsif SiteSetting.login_required? + redirect_to :login + end end def block_if_readonly_mode