open up different tabPanel according to different user permission
Closed this issue · 0 comments
Vicellken commented
Thank you for your package, it saves a lot!
I want to use user_info()$permissions == "..."
to control the appearance of certain tabPanel()
in fluidPage()
. It works when first login, but after logout, the re-login process requires to refresh the web-page, other wise the web-page just not render the uiOutput("2")
and uiOutput("3")
, as well as the glue()
in sidebar.
Do you have any idea why this happens?
ui <- dashboardPage(header = dashboardHeader(),
sidebar = dashboardSidebar(),
body = dashboardBody(
shinyjs::useShinyjs(),
tags$head(tags$style(".table{margin: 0 auto;}"),
tags$script(src="https://cdnjs.cloudflare.com/ajax/libs/iframe-resizer/3.5.16/iframeResizer.contentWindow.min.js",
type="text/javascript"),
includeScript("returnClick.js")
),
shinyauthr::loginUI("login"),
uiOutput("prelogin"), # same as uiOutput("user_table") in your example
uiOutput("afterlogin"), # here i encountered issue
HTML('<div data-iframe-height></div>')
))
server <- function(input, output, session) {
output$afterlogin <- renderUI({
afterloginUI()
})
## issue may related to here
afterloginUI <- reactive({
req(credentials()$user_auth)
if (user_info()$permissions == "standard") {
fluidPage(
tabsetPanel(type = "tabs",
tabPanel("1", uiOutput("1")),
tabPanel("2", uiOutput("2"))
)
)
} else if (user_info()$permissions == "admin") {
fluidPage(
tabsetPanel(type = "tabs",
tabPanel("1", uiOutput("1")),
tabPanel("2", uiOutput("2")),
tabPanel("3", uiOutput("3"))
)
)
}
})
}
Note: for uiOutput("2")
and uiOutput("3")
, there are calls in their server like observe({})
and observeEvent({})
, this is the major difference between uiOutput("1")
.
Thanks in advance!