Skip to content
Snippets Groups Projects
Commit 01a5d24c authored by ad0z's avatar ad0z Committed by Dieter Holvoet
Browse files

Issue #3396702 by ad0z, dieterholvoet, kreynen, nmangold: Regression related...

Issue #3396702 by ad0z, dieterholvoet, kreynen, nmangold: Regression related to InvalidArgumentException
parent 66cdbab9
No related branches found
No related tags found
1 merge request!14Simplify anonymous settings form validation, update user_login_path form element description
Pipeline #402963 failed
......@@ -114,7 +114,7 @@ class R4032LoginSubscriber extends HttpExceptionSubscriberBase {
// Check if the path should be ignored.
if (($noRedirectPages = trim($config->get('match_noredirect_pages') ?? ""))
&& (($this->pathMatcher->matchPath($currentPath, $noRedirectPages) && !$config->get('match_noredirect_negate'))
|| (!$this->pathMatcher->matchPath($currentPath, $noRedirectPages) && $config->get('match_noredirect_negate')))
|| (!$this->pathMatcher->matchPath($currentPath, $noRedirectPages) && $config->get('match_noredirect_negate')))
) {
return;
}
......
......@@ -2,10 +2,8 @@
namespace Drupal\r4032login\Form;
use Drupal\Component\Utility\UrlHelper;
use Drupal\Core\Form\ConfigFormBase;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Url;
use Drupal\user\Entity\User;
use Symfony\Component\DependencyInjection\ContainerInterface;
......@@ -119,16 +117,18 @@ class AnonymousSettingsForm extends ConfigFormBase {
// Check the path validity
// and whether the anonymous user can access the entered path.
if (!UrlHelper::isExternal($r4032loginUserLoginPath)
&& (($r4032loginUserLoginPath != '<front>') || ($r4032loginUserLoginPath = Url::fromRoute($r4032loginUserLoginPath)->toString()))
&& (!$this->pathValidator->getUrlIfValidWithoutAccessCheck($r4032loginUserLoginPath)
|| !($url = Url::fromUserInput($r4032loginUserLoginPath))
|| !$url->access(User::getAnonymousUser()))
) {
$url = $this->pathValidator->getUrlIfValidWithoutAccessCheck($r4032loginUserLoginPath);
if (!$url || (!$url->isExternal() && !$url->access(User::getAnonymousUser()))) {
$form_state->setErrorByName('user_login_path', $this->t("The user login form path '%path' is either invalid or a logged out user does not have access to it.", [
'%path' => $form_state->getValue('user_login_path'),
]));
}
// Make sure the path starts with a slash.
if (substr($r4032loginUserLoginPath, 0, 1) !== '/') {
$r4032loginUserLoginPath = '/' . $r4032loginUserLoginPath;
$form_state->setValue('user_login_path', $r4032loginUserLoginPath);
}
}
}
......
......@@ -54,6 +54,11 @@ class ChangeLoginFormPathTest extends BrowserTestBase {
'admin/config',
'user/customLogin',
],
[
'user/customLogin',
'admin/config',
'user/customLogin',
],
[
'https://www.drupal.org/user/login',
'admin/config',
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment