Is there a simple way for me to create a log-in page for my app? I want to render a ui with multiple tabs (ie. fluidPage(navbarPage(tabPanel("tab1", ...), tabPanel("tab2", ...),...))
conditional upon successful user authentication. I initiate a database connection with an R6
object, if it fails, I print out an "error" and the user can retry entering their credentials. If the connection is successful, I'd like to render the ui ( ui2
) I specify above.
ui <- fluidPage(fluidRow(column(width=12, textInput('uid', label =
"Enter your user id:"), passwordInput("pwd",
label = "Enter your password:"), actionButton("login",
"Login"), uiOutput("resulting_ui"), offset = 5)))
If you already set up a database that can hold usernames and passwords, you can have users enter their credentials, compare them to the ones in the database, and change a value of a reactiveVal()
based on that comparison. The value of that reactiveVal()
will control whether you show your UI or not.
For example you can use something like this:
logged <- reactiveVal(value = F)
# change the value of logged() when a user enters correct credentials
output$your_ui <- renderUI({
req(logged())
# your ui here...
})
For a more elaborated example take a look here:
https://github.com/yanirmor/shiny-user-management
Starting Shiny app after password input This did mostly resolve my question. I just had to make some minor changes to get it to work.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.