New password module
pwd_ui(id, tag_img = NULL, status = "primary", lan = NULL)
pwd_server(
input,
output,
session,
user,
update_pwd,
validate_pwd = NULL,
use_token = FALSE,
lan = NULL
)
Module's id.
A tags$img
to be displayed on the authentication module.
Bootstrap status to use for the panel and the button.
Valid status are: "default"
, "primary"
, "success"
,
"warning"
, "danger"
.
An language object. Should not be used directly.
Standard Shiny server arguments.
A reactiveValues
with a slot user
,
referring to the user for whom the password is to be changed.
A function
to perform an action when changing password is successful.
Two arguments will be passed to the function: user
(username) and password
(the new password). Must return a list with at least a slot result
with TRUE
or FALSE
, according if the update has been successful.
A function
to validate the password enter by the user.
Default is to check for the password to have at least one number, one lowercase,
one uppercase and be of length 6 at least.
Add a token in the URL to check authentication. Should not be used directly.
if (interactive()) {
library(shiny)
library(shinymanager)
ui <- fluidPage(
tags$h2("Change password module"),
actionButton(
inputId = "ask", label = "Ask to change password"
),
verbatimTextOutput(outputId = "res_pwd")
)
server <- function(input, output, session) {
observeEvent(input$ask, {
insertUI(
selector = "body",
ui = tags$div(
id = "module-pwd",
pwd_ui(id = "pwd")
)
)
})
output$res_pwd <- renderPrint({
reactiveValuesToList(pwd_out)
})
pwd_out <- callModule(
module = pwd_server,
id = "pwd",
user = reactiveValues(user = "me"),
update_pwd = function(user, pwd) {
# store the password somewhere
list(result = TRUE)
}
)
observeEvent(pwd_out$relog, {
removeUI(selector = "#module-pwd")
})
}
shinyApp(ui, server)
}