Is there any way to get the current user of a session of your R Shiny app?

67 Views Asked by At

My organization currently uses the basic subscription to R Shiny. Right now, I'm trying to set up one of our dashboards so that it can perform one of the following functionalities:

  1. Enable login (We've already been able to accomplish this with shinymanager).

  2. Upon successful login, save the name of the inputted user for the rest of that session.

This second step is where I'm stuck. If anybody has ever managed to accomplish this, please let me know. Our current login setup looks something like this:

(Outside of either ui or server):

credentials <- data.frame(
    user = ("sample_user", "sample_user_1"),
    password = ("password1", "password2"),
    admin = (TRUE, FALSE)
)

And within our server object we have this:

res_auth <- secure_server(
    check_credentials = check_credentials(credentials)
  )
  
output$auth_output <- renderPrint({
    reactiveValuesToList(credentials)
})

However, whenever I try to get some info about the session with session$user or session$userData, it is NULL.

1

There are 1 best solutions below

0
On

I found the solution. After the user is logged in, information about the session can be be found with auth_output(), and specifically user information with auth_output()$user.