I created a Flexdashboard with two tabs. I'm using shinymanager
package for authentication. In the shinymanager credentials, I created two users: "admin" and "manager." Now I want the admin user to have access to both tabs and the manager to only TAB A.
Here is my code:
---
title: "Flexdashboard"
output: flexdashboard::flex_dashboard
runtime: shiny
---
```{css}
.panel-auth {
position: fixed;
top:0;
bottom: 0;
left: 0;
right: 0;
background-color: #FFF;
opacity: 1;
z-index: 99997;
overflow-x: hidden;
overflow-y: scroll;
}
```
```{r setup, include=FALSE}
library(flexdashboard)
library(shiny)
library(shinymanager)
credentials <- data.frame(
user = c("admin", "manager"),
password = c("1234", "1234"),
stringsAsFactors = FALSE
)
```
```{r}
auth_ui(id = "auth")
auth <- callModule(
module = auth_server,
id = "auth",
check_credentials = check_credentials(credentials))
user_role <- "manager"
r_show_hide <- reactive({
if(user_role %in% auth$user) {
"hidden"
} else {
"show"
}
})
```
TAB A
=============================
### Chart
TAB B {.`r isolate(r_show_hide())`}
===============================
### Chart
I think that your approach cannot work by design, as the rendering happens before any user inputs are generated.
Having said that, I would simply use some
JavaScript
to hide the corresponding navbar items: