datastorm-open / shinymanager

Simple and secure authentification mechanism for single shiny applications.
https://datastorm-open.github.io/shinymanager/
381 stars 79 forks source link

Using a BS theme breaks some functionality in admin mode #137

Open Jeff-Thompson12 opened 2 years ago

Jeff-Thompson12 commented 2 years ago

We are working on an app and were using a bootstrap theme using library bslib. This has caused a few bugs when accessing the administrative mode.

  1. The floating action button jumps from the bottom right to the bottom left.
  2. Some buttons no longer dismiss the modal. For instance, if you edit a user and click "CONFIRM CHANGE", the modal does not close.
  3. Some buttons break the overflow of the page. For instance, if you add a new user, the vertical scroll bar disappears and the overflow attribute of the html body is set at hidden.

Reproducible example is below.

library(shiny)
library(shinymanager)
library(bslib)

credentials <- data.frame(
  user = c("shiny", "shinymanager"),
  password = c("azerty", "12345"),
  start = c("2019-04-15"),
  expire = c(NA, NA),
  admin = c(FALSE, TRUE),
  comment = "Simple and secure authentification mechanism 
  for single ‘Shiny’ applications.",
  stringsAsFactors = FALSE
)

create_db(credentials, file.path('credentials.sqlite'))

theme <- bs_theme(
  bootswatch = "lux",
  version = 5,
  primary = "#24305E",
  secondary = "#F76C6C",
)

ui <- fluidPage(
  tags$h2("My secure application"),
  verbatimTextOutput("auth_output"),
  theme = theme
)

# Wrap your UI with secure_app
ui <- secure_app(ui,
                 theme = theme,
                 enable_admin = TRUE)

server <- function(input, output, session) {

  res_auth <- secure_server(
    check_credentials = check_credentials('credentials.sqlite')
  )

  output$auth_output <- renderPrint({
    reactiveValuesToList(res_auth)
  })

}

shinyApp(ui, server)