library(shiny)
library(shinymanager)
inactivity <- "function idleTimer() {
var t = setTimeout(logout, 120000);
window.onmousemove = resetTimer; // catches mouse movements
window.onmousedown = resetTimer; // catches mouse movements
window.onclick = resetTimer; // catches mouse clicks
window.onscroll = resetTimer; // catches scrolling
window.onkeypress = resetTimer; //catches keyboard actions
function logout() {
window.close(); //close the window
}
function resetTimer() {
clearTimeout(t);
t = setTimeout(logout, 120000); // time is in milliseconds (1000 is 1 second)
}
}
idleTimer();"
credentials <- data.frame(
user = c("1", "fanny", "victor", "benoit"),
password = c("1", "azerty", "12345", "azerty"),
# comment = c("alsace", "auvergne", "bretagne"), %>%
stringsAsFactors = FALSE
)
ui <- secure_app(head_auth = tags$script(inactivity),
# classic ui logic
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 <- renderPrint({
reactiveValuesToList(res_auth)
})
# classic server logic
}
shinyApp(ui, server)
有一种方法可以用shinymanager包识别不同的用户吗?类似这样的东西:
if(user=="fanny"){
#one dashboard
}
if(user=="benoit"){
#another dashboard
}
我的意图是根据登录者创建不同的应用程序……如果用户是Benny,则显示一个应用程序(如果是Benoit(,显示另一个,如果是Victor,则显示另一应用程序。
在另一个线程中也提供了类似的答案。解决方案是将凭据放入反应值中。您可以使用creds_reactive(($user访问当前登录的用户,并定义自定义应用