Skip to content

Instantly share code, notes, and snippets.

@gomesfellipe
Created May 8, 2019 16:27
Show Gist options
  • Save gomesfellipe/2bf66f470d47a7ab8ae899233eb3cdcc to your computer and use it in GitHub Desktop.
Save gomesfellipe/2bf66f470d47a7ab8ae899233eb3cdcc to your computer and use it in GitHub Desktop.
# Inluir no global -------------------------------------------------------
Logged = FALSE
my_username <- "appgenalim"
my_password <- "genalim"
# -------------------------------------------------------------------------
# Autenticacao ------------------------------------------------------------
## Incluir codigo abaixo no servidor
values <- reactiveValues(authenticated = FALSE)
# Return the UI for a modal dialog with data selection input. If 'failed'
# is TRUE, then display a message that the previous value was invalid.
dataModal <- function(failed = FALSE) {
modalDialog(
# textInput("username", "Username:"),
h3("Bem vindo ao aplicativo", tags$b("appGENALIM"), "!"),
passwordInput("password", "Senha:"),
footer = tagList(# modalButton("Cancel"),
actionButton("ok", "OK"))
)
}
# Show modal when button is clicked.
# This `observe` is suspended only whith right user credential
obs1 <- observe({
showModal(dataModal())
})
# When OK button is pressed, attempt to authenticate. If successful,
# remove the modal.
obs2 <- observe({
req(input$ok)
isolate({
Username <- my_username #input$username
Password <- input$password
})
Id.username <- which(my_username == Username)
Id.password <- which(my_password == Password)
if (length(Id.username) > 0 & length(Id.password) > 0) {
if (Id.username == Id.password) {
Logged <<- TRUE
values$authenticated <- TRUE
obs1$suspend()
removeModal()
} else {
values$authenticated <- FALSE
}
}
})
output$dataInfo <- renderPrint({
if (values$authenticated)
"OK!!!!!"
else
"You are NOT authenticated"
})
# -----------------------------------------------------
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment