How to make menu link show for certain roles? I want to add "Login" and "Logout" to the same menu but only for the right role. In previous versions of Drupal, you would just add /user/login and /user/logout to a menu and it would only render one or the other based on if they actually were logged in or not.

However in D8, it looks like the Logout link shows regardless... is there a way to replicate this without creating multiple menus?
In D8 this is a menu link class, which you can add to a menu in *.links.menu.yml:

mymodule.links.menu.yml

mymodule.logout:
  weight: 10
  menu_name: mymenu
  class: Drupal\user\Plugin\Menu\LoginLogoutMenuLink


This class shows Log in or Log out for user roles authenticated or not:

  public function getTitle() {
    if ($this-&gt;currentUser-&gt;isAuthenticated()) {
      return $this-&gt;t('Log out');
    }
    else {
      return $this-&gt;t('Log in');
    }
  }


and links it to the corresponding route:

  public function getRouteName() {
    if ($this-&gt;currentUser-&gt;isAuthenticated()) {
      return 'user.logout';
    }
    else {
      return 'user.login';
    }
  }