Adding a password

So far, we have learned how to develop a Shiny application. Since the application is exposing so much data to the outside world, it needs to be protected by unauthorized means. For that, we can provide password authentication. Shiny provides a control for achieving this task, called passwordInput (https://shiny.rstudio.com/reference/shiny/latest/passwordInput.html):

passwordInput(inputId, label, value = "", width = NULL,placeholder = NULL) 

Let's see an example with passwordInput:

ui <- fluidPage( 
    passwordInput("password", "Password:"), 
    actionButton("go", "Go"), 
    verbatimTextOutput("value") 
  ) 
  server <- function(input, output) { 
    output$value <- renderText({ 
      req(input$go) 
      isolate(input$password) 
    }) 
  } 

Here is the output:

In the preceding application, the UI section has passwordInput(), which converts the entered text into dots and the inputted value is stored in a password variable that can further be used in reactive processes. The code can be copied and pasted into R Script and executed as a simple Shiny application.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset