summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlex Pott2015-09-26 12:10:52 (GMT)
committerAlex Pott2015-09-26 12:10:52 (GMT)
commit18802aaa64599df52d4b4fe79da7a1ba4b0cc0cc (patch)
tree6a8ccfbe62789ba8144af10b3bc612c4bc8a20ad
parent64d6415c475ee4fd1b55de48e4a1b316cb7a0861 (diff)
Issue #893868 by ericbroder, jaxxed, iMiksu, yogen.prasad, a.ross, mrfelton, VM, lauriii, Jasu_M: Login block not shown on user/register
-rw-r--r--core/modules/user/src/Plugin/Block/UserLoginBlock.php2
-rw-r--r--core/modules/user/src/Tests/UserBlocksTest.php24
2 files changed, 25 insertions, 1 deletions
diff --git a/core/modules/user/src/Plugin/Block/UserLoginBlock.php b/core/modules/user/src/Plugin/Block/UserLoginBlock.php
index 3831dd7..846f22e 100644
--- a/core/modules/user/src/Plugin/Block/UserLoginBlock.php
+++ b/core/modules/user/src/Plugin/Block/UserLoginBlock.php
@@ -77,7 +77,7 @@ class UserLoginBlock extends BlockBase implements ContainerFactoryPluginInterfac
*/
protected function blockAccess(AccountInterface $account) {
$route_name = $this->routeMatch->getRouteName();
- if ($account->isAnonymous() && !in_array($route_name, array('user.register', 'user.login', 'user.logout'))) {
+ if ($account->isAnonymous() && !in_array($route_name, array('user.login', 'user.logout'))) {
return AccessResult::allowed()
->addCacheContexts(['route.name', 'user.roles:anonymous']);
}
diff --git a/core/modules/user/src/Tests/UserBlocksTest.php b/core/modules/user/src/Tests/UserBlocksTest.php
index 9ac5ae9..f16e31e 100644
--- a/core/modules/user/src/Tests/UserBlocksTest.php
+++ b/core/modules/user/src/Tests/UserBlocksTest.php
@@ -39,6 +39,30 @@ class UserBlocksTest extends WebTestBase {
$this->drupalLogout($this->adminUser);
}
+ /**
+ * Tests that user login block is hidden from user/login.
+ */
+ function testUserLoginBlockVisibility() {
+ // Array keyed list where key being the URL address and value being expected
+ // visibility as boolean type.
+ $paths = [
+ 'node' => TRUE,
+ 'user/login' => FALSE,
+ 'user/register' => TRUE,
+ 'user/password' => TRUE,
+ ];
+ foreach ($paths as $path => $expected_visibility) {
+ $this->drupalGet($path);
+ $elements = $this->xpath('//div[contains(@class,"block-user-login-block") and @role="form"]');
+ if ($expected_visibility) {
+ $this->assertTrue(!empty($elements), 'User login block in path "' . $path . '" should be visible');
+ }
+ else {
+ $this->assertTrue(empty($elements), 'User login block in path "' . $path . '" should not be visible');
+ }
+ }
+ }
+
/**
* Test the user login block.
*/