Problem/Motivation
If a user tries to login via SAML with an account that's already on the site and not linked and linking is not allowed, the actual error message can get lost due to error 500 being thrown.
Steps to reproduce
(Seen on Acquia Site Factory - I'm sure it can be reproduced elsewhere, but didn't try)
* Install a D9/D8 site
* Try logging in with SAML
* Site throws error 500 and logs show:
Error: Call to a member function getAccountName() on null in Drupal\samlauth\SamlService->doLogin() (line 438 of /mnt/www/html/david201live/docroot/modules/contrib/samlauth/src/SamlService.php) #0 /mnt/www/html/david201live/docroot/modules/contrib/samlauth/src/SamlService.php(336): Drupal\samlauth\SamlService->doLogin('urn:acquia:acsf...', NULL)
May 19 13:44:13 web-8 david201live[15703]: #1 /mnt/www/html/david201live/docroot/modules/contrib/samlauth/src/Controller/SamlController.php(267): Drupal\samlauth\SamlService->acs()
May 19 13:44:13 web-8 david201live[15703]: #2 /mnt/www/html/david201live/docroot/modules/contrib/samlauth/src/Controller/ExecuteInRenderContextTrait.php(184): Drupal\samlauth\Controller\SamlController->Drupal\samlauth\Controller\{closure}()
May 19 13:44:13 web-8 david201live[15703]: #3 /mnt/www/html/david201live/docroot/core/lib/Drupal/Core/Render/Renderer.php(573): Drupal\samlauth\Controller\SamlController->Drupal\samlauth\Controller\{closure}()
May 19 13:44:13 web-8 david201live[15703]: #4 /mnt/www/html/david201live/docroot/modules/contrib/samlauth/src/Controller/ExecuteInRenderContextTrait.php(121): Drupal\Core\Render\Renderer->executeInRenderContext(Object(Drupal\Core\Render\RenderContext), Object(Closure))
May 19 13:44:13 web-8 david201live[15703]: #5 /mnt/www/html/david201live/docroot/modules/contrib/samlauth/src/Controller/ExecuteInRenderContextTrait.php(222): Drupal\samlauth\Controller\SamlController->executeInRenderContext(Object(Closure), 'processing SAML...')
May 19 13:44:13 web-8 david201live[15703]: #6 /mnt/www/html/david201live/docroot/modules/contrib/samlauth/src/Controller/SamlController.php(270): Drupal\samlauth\Controller\SamlController->getTrustedRedirectResponse(Object(Closure), 'processing SAML...', '')
May 19 13:44:13 web-8 david201live[15703]: #7 [internal function]: Drupal\samlauth\Controller\SamlController->acs()
May 19 13:44:13 web-8 david201live[15703]: #8 /mnt/www/html/david201live/docroot/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(123): call_user_func_array(Array, Array)
May 19 13:44:13 web-8 david201live[15703]: #9 /mnt/www/html/david201live/docroot/core/lib/Drupal/Core/Render/Renderer.php(573): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
May 19 13:44:13 web-8 david201live[15703]: #10 /mnt/www/html/david201live/docroot/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(124): Drupal\Core\Render\Renderer->executeInRenderContext(Object(Drupal\Core\Render\RenderContext), Object(Closure))
May 19 13:44:13 web-8 david201live[15703]: #11 /mnt/www/html/david201live/docroot/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(97): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array)
May 19 13:44:13 web-8 david201live[15703]: #12 /mnt/www/html/david201live/vendor/symfony/http-kernel/HttpKernel.php(158): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
May 19 13:44:13 web-8 david201live[15703]: #13 /mnt/www/html/david201live/vendor/symfony/http-kernel/HttpKernel.php(80): Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object(Symfony\Component\HttpFoundation\Request), 1)
May 19 13:44:13 web-8 david201live[15703]: #14 /mnt/www/html/david201live/docroot/core/lib/Drupal/Core/StackMiddleware/Session.php(57): Symfony\Component\HttpKernel\HttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
May 19 13:44:13 web-8 david201live[15703]: #15 /mnt/www/html/david201live/docroot/core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php(47): Drupal\Core\StackMiddleware\Session->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
May 19 13:44:13 web-8 david201live[15703]: #16 /mnt/www/html/david201live/docroot/core/modules/page_cache/src/StackMiddleware/PageCache.php(106): Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
May 19 13:44:13 web-8 david201live[15703]: #17 /mnt/www/html/david201live/docroot/core/modules/page_cache/src/StackMiddleware/PageCache.php(85): Drupal\page_cache\StackMiddleware\PageCache->pass(Object(Symfony\Component\HttpFoundation\Request), 1, true)
May 19 13:44:13 web-8 david201live[15703]: #18 /mnt/www/html/david201live/docroot/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php(47): Drupal\page_cache\StackMiddleware\PageCache->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
May 19 13:44:13 web-8 david201live[15703]: #19 /mnt/www/html/david201live/docroot/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php(52): Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
May 19 13:44:13 web-8 david201live[15703]: #20 /mnt/www/html/david201live/vendor/stack/builder/src/Stack/StackedHttpKernel.php(23): Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
May 19 13:44:13 web-8 david201live[15703]: #21 /mnt/www/html/david201live/docroot/core/lib/Drupal/Core/DrupalKernel.php(706): Stack\StackedHttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
May 19 13:44:13 web-8 david201live[15703]: #22 /mnt/www/html/david201live/docroot/index.php(19): Drupal\Core\DrupalKernel->handle(Object(Symfony\Component\HttpFoundation\Request))
May 19 13:44:13 web-8 david201live[15703]: #23 {main}. request_id="v-4b9f4d38-b8a8-11eb-bdfc-339f786bee14"
Proposed resolution
See attached patch.
After applying said patch, the actual error message is displayed on the UI.
Comments
Comment #3
roderikOuch. And here I am trying to promote not matching/linking users.
This is a clear case of automated tests being missing.
Thank you! Committed. 8-x.3-2 is being built.