R/password_input.R

Defines functions password_input

Documented in password_input

#' A modification of \code{shiny::passwordInput}
#'
#' This modified version of Shiny's \code{passwordInput()} does not actually send the password
#' to our Shiny server.  It is just a regular password input that always keeps your
#' user's password on the client.  The password is used to sign the user in and then
#' converted to a JWT by Firebase, all on the client, before it is sent to your Shiny
#' server.
#'
#' @param input_id The \code{input} slot that will be used to access the value.
#' @param label Display label for the control, or \code{NULL} for no label.
#' @param value Initial value.
#' @param style Character string of in-line CSS to style the input.
#' @param placeholder A character string giving the user a hint as to what can
#' be entered into the control. Internet Explorer 8 and 9 do not support this option.
#'
#' @return the UI to create a password input.
#'
#' @importFrom htmltools tags tagList
#'
#' @export
#'
password_input <- function(
  input_id,
  label = htmltools::tagList(icon("unlock-alt"), "Password"),
  value = "",
  style = "",
  placeholder = NULL
) {
  htmltools::tags$div(
    class = "form-group",
    style = style,
    htmltools::tags$label(
      label,
      class = "control-label",
      class = if (is.null(label)) "shiny-label-null",
      `for` = input_id
    ),
    htmltools::tags$input(
      id = input_id,
      type = "password",
      class = "form-control",
      value = value,
      placeholder = placeholder
    )
  )
}

Try the polished package in your browser

Any scripts or data that you put into this service are public.

polished documentation built on Feb. 16, 2023, 8:02 p.m.