From c3c7f7c893f5539ee0ba805ea35e3d129fc9d973 Mon Sep 17 00:00:00 2001 From: laryn Date: Fri, 10 Feb 2023 10:41:26 -0600 Subject: [PATCH] Issue #15: Make sure to respect the 'activated' setting. Fixes #15. --- simplesamlphp_auth.module | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/simplesamlphp_auth.module b/simplesamlphp_auth.module index 3b6369d..fe25df7 100644 --- a/simplesamlphp_auth.module +++ b/simplesamlphp_auth.module @@ -535,7 +535,7 @@ function simplesamlphp_auth_block_info() { * Checks to see if authentication via SimpleSAMLphp should be activated. * * @param bool $show_inactive_msg - * Whether to display the "module not activated" message + * Whether to display the "module not activated" message. * * @return bool * TRUE/FALSE @@ -554,19 +554,16 @@ function _simplesamlphp_auth_isEnabled($show_inactive_msg = FALSE) { $failure = t('SimpleSAMLphp could not be found at %basedir . The simplesamlphp_auth module cannot function until the path to the local SimpleSAMLphp instance is configured.', array('%basedir' => $basedir)); watchdog('simplesamlphp_auth', $failure, NULL, WATCHDOG_WARNING); } - } - - // If there were no failures, then it should be activated. - if (!$failure) { - return TRUE; - } - else { - - // Communicate but don't be too annoying. - if ($show_inactive_msg && (1 == $user->uid || user_access('access administration pages')) && (preg_match('/admin\/people/', request_uri()) || preg_match('/admin\/modules/', request_uri()) || preg_match('/admin\/config/', request_uri()))) { - backdrop_set_message($failure); + // If there were no failures, then it should be activated. + if (!$failure) { + return TRUE; } } + // If we made it this far, it's not activated. + // Communicate but don't be too annoying. + if ($failure && $show_inactive_msg && (1 == $user->uid || user_access('access administration pages')) && (preg_match('/admin\/people/', request_uri()) || preg_match('/admin\/modules/', request_uri()) || preg_match('/admin\/config/', request_uri()))) { + backdrop_set_message($failure); + } return FALSE; } @@ -616,9 +613,9 @@ function _simplesamlphp_auth_get_default_name($account) { ) { throw new Exception(t('There was no set attribute named "%auth_user_name_attr" returned for user %uid.', array( - '%auth_user_name_attr' => $auth_user_name_attr, - '%uid' => $account, - ))); + '%auth_user_name_attr' => $auth_user_name_attr, + '%uid' => $account, + ))); } $default_name = $_simplesamlphp_auth_saml_attributes[$auth_user_name_attr][0]; }