r - 如何使用 shinymanager 包为不同的登录创建不同的应用程序?R闪亮
问题描述
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 访问当前登录的用户并定义自定义应用程序
推荐阅读
- php - 如何在 laravel 中创建动态选择选项 chantiers ouvrages?
- perl - 在 perl 中将哈希推入数组,结果无法理解
- java - 创建一个简单的应用程序,无法获得清晰的按钮来工作
- java - 如何比较 Java 中三个数组列表的大小?
- filter - 如何在添加自定义过滤器选项中编辑 Odoo 11 中的过滤器和字段
- python - 包含所有组合列表的功能
- r - 在 2 列 Dataframe 上应用 API 函数,输出第三列
- jmeter - 是否必须在 HTTP 请求默认值中检查“检索所有嵌入式资源”以进行性能测试?
- java - Spark结构化流:为什么java代码使用DataSet而scala使用DataFrame类型?
- php - 如何连接到名称中带有分号的数据库?