Skip to content

R package that provides Shiny modules to easily implement One-Time Password (OTP) authentication in your Shiny applications.

Notifications You must be signed in to change notification settings

dejan94it/shinyOTP

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

shinyOTP

shinyOTP is an R package that provides Shiny modules to easily implement One-Time Password (OTP) authentication in your Shiny applications.

Installation

At the moment you can install only this version from GitHub:

# Install devtools if necessary
# install.packages("devtools")

devtools::install_github("dejan94it/shinyOTP")

Usage

Set email and password from which you want to send OTP code as environmental variable, and then just use ui and server functions.

Here is a minimal Shiny App:

library(shiny)
library(shinyOTP)

Sys.setenv(SMTP_EMAIL = "youremail")
Sys.setenv(SMTP_PASSWORD = "yourpassword")

ui <- fluidPage(
  fluidRow(otp_ui("otp_module")),
  fluidRow(htmlOutput("do_something"))
)

server <- function(input, output, session) {
  is_verified <- otp_server(
    "otp_module",              
    smtp_email = "SMTP_EMAIL",      
    smtp_password = "SMTP_PASSWORD",
    smtp_host = "yoursmtphost",  #example: smtp.gmail.com      
    smtp_port = 465,  #search the port number of your smtp host                         
    ssl = TRUE,  #paired with host and port usually                            
  )
  
  output$do_something <- renderUI({
    if(is_verified()){ 
      return(h2("Do something when verified!")) 
    } else {
      return(NULL)
    } 
  })
}

shinyApp(ui, server)

About

R package that provides Shiny modules to easily implement One-Time Password (OTP) authentication in your Shiny applications.

Topics

Resources

Stars

Watchers

Forks

Languages