Hi,
I was wondering if it's possible to use the internal ShinyApps.io authentication method (available from the standard plan) to validate different user profiles whitin a Shiny app.
I've used packages such as Shinymanager that allow the control of user profiles, password management, etc. With this package I've managed to asign different roles to the users by using an ObserveEvent as a validation process to select which data to show, a reproducible example can be as follows:
library(shiny)
library(shinymanager)
library(dplyr)
#Credentias df
creds <- data.frame(user = c('user1','user2'),
password = c('pass1','pass2'),
df = c('iris','cars')
)
#UI
ui <- fluidPage(
uiOutput('title'),
tableOutput('table')
)
#Shiny manager authentication UI
ui <- secure_app(ui, language = 'en')
#SERVER
server <- function(input, output) {
#Reactive values to store the data
reac_v <- reactiveValues()
#Shiny manager credentials check
res_auth <- secure_server(check_credentials = check_credentials(creds))
#ObserveEvent to validate user profile, select the data, and store it in reac_v
observeEvent(res_auth,{
x <- reactiveValuesToList(res_auth)
if(length(x) > 0){
user <- x$user
title <- paste0('This is the ',user)
validator <- x$df
df <- switch(validator,
iris = head(iris),
cars = head(cars))
reac_v$title <- title
reac_v$df <- df
}
})
#Outputs
output$title <- renderText(reac_v$title)
output$table <- renderTable(reac_v$df)
}
shinyApp(ui = ui, server = server)
It's posible to use a similar validation proces of user profiles without Shinymanager, but using ShinyApps.io internal authentication instead?
If it is, what approach or method should be used?
Appreciated!