On logout, whatever is visible in a dashboard body stays visible, and the login prompt simply pushes it down. Is there a way to intercept the logout and set to a blank tab - or a simpler option?
library(shiny)
library(shinyauthr)
library(shinyjs)
library(shinydashboard)
# dataframe that holds usernames, passwords and other user data
user_base <- data.frame(
user = c("user1", "a"),
password = c("pass1", ""),
permissions = c("admin", "standard"),
name = c("User One", "User Two"),
stringsAsFactors = FALSE
)
header <- dashboardHeader(title = 'Shiny Auth Test')
sidebar <- dashboardSidebar(
shinyauthr::logoutUI(id = 'logout', label = 'Log out', icon = icon('times-circle'))
,uiOutput('sidebarpanel')
)
body <- dashboardBody(
useShinyjs()
,shinyauthr::loginUI('login')
,uiOutput('body')
)
ui <- dashboardPage(header, sidebar, body, skin = 'purple')
server <- function(input, output, session) {
# call the logout module with reactive trigger to hide/show
logout_init <- callModule(shinyauthr::logout,
id = "logout",
active = reactive(credentials()$user_auth))
# call login module supplying data frame, user and password cols
# and reactive trigger
credentials <- callModule(shinyauthr::login,
id = "login",
data = user_base,
user_col = user,
pwd_col = password,
log_out = reactive(logout_init()))
# pulls out the user information returned from login module
user_data <- reactive({credentials()$info})
output$sidebarpanel <- renderUI({
req(credentials()$user_auth)
div(
sidebarMenu(id = "sidebar"
,menuItem('Chart', tabName = 't_item1', icon = icon('chart-bar'))
,menuItem('Widget', tabName = 't_item2', icon = icon('ambulance'))
,menuItem('' , tabName = 't_blank')
)
)
})
output$body <- renderUI({
tabItems(
tabItem(tabName = "t_item1", h2("Chart tab content"))
,tabItem(tabName = "t_item2", h2("Widget tab content"))
,tabItem(tabName = "t_blank", h2(''))
)
})
}
shinyApp(ui = ui, server = server)
Great package, it's been really useful - thanks!
On logout, whatever is visible in a dashboard body stays visible, and the login prompt simply pushes it down. Is there a way to intercept the logout and set to a blank tab - or a simpler option?