Please see the code below. I met a problem when running a shiny app under a secure page. The "onSessionEnded" function is triggered once when I log into my account. And then it's triggered once again when I close the app.
Do you know how to make "onSessionEnded" not triggered when I log into the account? Ideally, "onSessionEnded" should only be triggered when the app is closed, right? Could anybody give me some suggestions?
You can run the code directly with username: a
and password: a
library(shiny)
library(shinymanager)
credentials <- data.frame(
user = c("a", "b"),
password = c("a", "b"),
stringsAsFactors = FALSE
)
ui <- fluidPage(
verbatimTextOutput("auth_output")
)
ui <- secure_app(ui)
lang <- shinymanager:::language$new()
lang$add(
"Please authenticate" = "Test Page",
"Username:" = "Username:",
"Password:" = "Password:",
"Login" = "Sign in"
)
server <- function(input, output, session) {
res_auth <- secure_server(
check_credentials = check_credentials(credentials)
)
output$auth_output <- renderPrint({
reactiveValuesToList(res_auth)
})
session$onSessionEnded(function() {
print("onSessionEnded Run!!!")
})
}
shinyApp(ui, server)