Im trying to print text and reactive object in the same line using print() and paste() but it does not work.
# define some credentials
credentials <- data.frame(
user = c("shiny", "shinymanager"), # mandatory
password = c("azerty", "12345"), # mandatory
start = Sys.Date(), # optinal (all others)
expire = c(NA, "2019-12-31"),
admin = c(FALSE, TRUE),
comment = "Simple and secure authentification mechanism
for single ‘Shiny’ applications.",
stringsAsFactors = FALSE
)
library(shiny)
library(shinymanager)
ui <- fluidPage(
tags$h2("My secure application"),
uiOutput("auth_output")
)
# Wrap your UI with secure_app
ui <- secure_app(ui)
server <- function(input, output, session) {
# call the server part
# check_credentials returns a function to authenticate users
res_auth <- secure_server(
check_credentials = check_credentials(credentials)
)
output$auth_output <- renderText({
print(paste0(h4("Name:"),h4(res_auth$user)))
})
# your classic server logic
}
shinyApp(ui, server)
CodePudding user response:
What jumps out to me is renderText is usually paired with verbatimTextOutput. If you want to use uiOutput you should pair it with renderUI in the server code.
That being said, if you are expecting it to display an h4 heading in the UI, you won't get what you expect. h4 returns a shiny.tag object. paste0 will coerce these to characters. You more likely want to create your text then use it to create the h4.
output$auth_output <- renderUI({
h4(paste0("Name:", res_auth$user))
})
