Shiny manager authentication for an specific dashboard tab?

Hello, good night everyone. I am working on a dashboard app, but I would like to know if it is possible for the app to ask for authentication in a specific tab panel. I tried to do something like that but I can't get it to work, do you know if it's possible with shinymanager or with conditionals?

The code im testing is the following:

if (interactive()) {
  library(shiny)
  library(bs4Dash)
  library(shinymanager)
  
  credentials <- data.frame(
    user = c("shiny", "shinymanager"),
    password = c("azerty", "12345"),
    stringsAsFactors = FALSE
  )
  
  shinyApp(
    ui = bs4DashPage(
      sidebar_collapsed = TRUE,
      controlbar_collapsed = TRUE,
      enable_preloader = FALSE,
      loading_duration =  2,
      navbar = bs4DashNavbar(skin = "dark"),
      body = bs4DashBody(
        bs4TabItems(
          bs4TabItem(
            tabName = "tab1",
            p("xd")
          )
        )
      ),
      sidebar = bs4DashSidebar(
        skin = "dark",
        bs4SidebarMenu(
          id = "test",
          bs4SidebarMenuItem(
            tabName = "tab1",
            text = "Tab 1"
          ),
          secure_app(bs4SidebarMenuItem(
            tabName = "tab2",
            text = "Tab 2"
          )),
          bs4SidebarMenuItem(
            text = "Click me pleaaaaase",
            bs4SidebarMenuSubItem(
              tabName = "subtab1",
              text = "Tab 3"
            ),bs4SidebarMenuSubItem(
              tabName = "subtab2",
              text = "Tab 4"
            )
          )
        )
      ),
      controlbar = bs4DashControlbar(skin = "light"),
      footer = bs4DashFooter()
    ),
    server = function(input, output, session) {
      
      res_auth <- secure_server(
        check_credentials = check_credentials(credentials)
      )
      
      observeEvent(input$test, {
        if (input$test == "subtab1") {
          showModal(modalDialog(
            title = "Thank you so much",
            "You clicked me! This event is the result of
           an input bound to the menu. By adding an id to the
           bs4SidebarMenu, input$id will give the currently selected
           tab. This is useful to trigger some events.",
            easyClose = TRUE,
            footer = NULL
          ))
        }
      })
    }
  )
}

This topic was automatically closed 54 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.