Conditionally render page-links based on ROLE auth

Hi, I’m trying to conditionally render a link “AdminPage” in my createDrawer() function of my MainLayout class. The link “AdminPage” should only be visible to user’s with Role=“admin.” In createDrawer() after creating my RouterLinks I have added a SecurityContextHolder to get the authentication of the current user, but it is not working. Currently it will not displaying the AdminPage link for any users, even those with the Role of “admin”. Any help would be appreciated :slightly_smiling_face:

private void createDrawer() {
        RouterLink AdminPage = new RouterLink("AdminPage", AdminPage.class); 
        Authentication auth = SecurityContextHolder.getContext().getAuthentication(); // get current user
        if (auth != null && auth.getAuthorities().stream().anyMatch(a -> a.getAuthority().equals("admin"))) {
            AdminPage.setVisible(true);
        } else {
AdminPage.setVisible(false);
}
addToDrawer(new VerticalLayout( 
            AdminPage));
}

It could be case sensitive and the role could be ADMIN instead of admin.