0
# Init DB using credentials data
credentials <- data.frame(
  user = c("shiny", "shinymanager"),
  password = c("azerty", "12345"),
  # password will automatically be hashed
  admin = c(FALSE, TRUE),
  stringsAsFactors = FALSE
)

# you can use keyring package to set database key
library(keyring)
key_set("R-shinymanager-key", "obiwankenobi")

# Init the database
create_db(
  credentials_data = credentials,
  sqlite_path = "path/to/database.sqlite", # will be created
  passphrase = key_get("R-shinymanager-key", "obiwankenobi")
  # passphrase = "passphrase_wihtout_keyring"
)

# Wrap your UI with secure_app, enabled admin mode or not
body <- dashboardBody(shinyjs::useShinyjs(),  tags$head(
  tags$link(rel = "stylesheet", type = "text/css", href = "style.css"),
  tags$script(src = "myscript.js"),
), 
verbatimTextOutput("auth_output")
)

header <- dashboardHeader(title = tags$a(
        href = "#",
        tags$img(
          src = "my-logo.png",
          height = "80px",
          width = "170px",
        ),
      ),

)


ui <- dashboardPage(title = "Adtree",header,
                    dashboardSidebar(disable = TRUE),
                    body, skin = "blue")
ui <- secure_app(ui, enable_admin = TRUE)


server <- function(input, output, session) {
  
  # check_credentials directly on sqlite db
  res_auth <- secure_server(
    check_credentials = check_credentials(
        "path/to/database.sqlite",
        passphrase = key_get("R-shinymanager-key", "obiwankenobi")
        # passphrase = "passphrase_wihtout_keyring"
    )
  )
  
  output$auth_output <- renderPrint({
    reactiveValuesToList(res_auth)
  })
  
  # your classic server logic
  ...
}

okay so this is my code

tags$a(
        href = "#",
        tags$img(
          src = "my-logo.png",
          height = "80px",
          width = "170px",
        ),
      ),

i use it to input my company logo at the left corner, i alrready tried not using shinyauthr ui <- secure_app(ui, enable_admin = TRUE) and it run perfectly, the logo appear and not gives an error like so :

Error in dashboardHeader(title = tags$a(href = "#", tags$img(src = "www/my-logo.png",  : 
  argument is missing, with no default

for example if i remove the image code to dashboardHeader(title = "testing") it also run perfectly, "testing" will show for the header title. So how to put image in ui wrapper using shinyauthr or maybe shinyauthr doesn't support image?

Phil
  • 7,287
  • 3
  • 36
  • 66

0 Answers0