Shiny UI module to be used with signinServer.

signinUI(
  id,
  ...,
  .header = NULL,
  .add_forgotpw = TRUE,
  .add_btn_signup = TRUE,
  cookie_expiry = 7
)

Arguments

id

The ID for the UI module.

...

Additional arguments to be passed to the shiny::wellPanel function.

.header

header for the sign-in panel, defaults to NULL.

.add_forgotpw

logical to add password recovery feature, defaults to TRUE.

.add_btn_signup

logical to add sign-up feature, defaults to FALSE.

cookie_expiry

number of days to request browser to retain signin cookie

Value

Shiny UI sign-in panel with text inputs for username and password, btn_sigin action button, and optional features, including btn_fogortpw

action link to password recovery panel and btn_signup action button to sign-up panel

Examples


library(shiny)
library(shinyAuthX)

# dataframe that holds usernames, passwords and other user data
users_base <- create_dummy_users()

ui <- fluidPage(
  # add signout button UI
  div(class = "pull-right", signoutUI(id = "signout")),

  # add signin panel UI function without signup or password recovery panel
  signinUI(id = "signin", .add_forgotpw = FALSE, .add_btn_signup = FALSE),

  # setup output to show user info after signin
  verbatimTextOutput("user_data")
)

server <- function(input, output, session) {
  # Export reactive values for testing
  exportTestValues(
    auth_status = credentials()$user_auth,
    auth_info   = credentials()$info
  )

  # call the signout module with reactive trigger to hide/show
  signout_init <- signoutServer(
    id = "signout",
    active = reactive(credentials()$user_auth)
  )

  # call signin module supplying data frame,
  credentials <- signinServer(
    id = "signin",
    users_db = users_base,
    sodium_hashed = TRUE,
    reload_on_signout = FALSE,
    signout = reactive(signout_init())
  )

  output$user_data <- renderPrint({
    # use req to only render results when credentials()$user_auth is TRUE
    req(credentials()$user_auth)
    str(credentials())
  })
}

if (interactive()) shinyApp(ui = ui, server = server)