diff --git a/DESCRIPTION b/DESCRIPTION index dd911c6..7fca7c9 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: shiny.reglog Title: Optional Login and Registration Module System for ShinyApps -Version: 0.2.0.1 +Version: 0.2.0.2 Authors@R: person(given = "Michal", family = "Kosinski", diff --git a/R/database_creation.R b/R/database_creation.R index e854741..7960080 100644 --- a/R/database_creation.R +++ b/R/database_creation.R @@ -1,6 +1,6 @@ -#' Function to create new empty sqlite database +#' Function to create new empty 'SQLite' database #' -#' @param output_file path to new sqlite database. After creation you need to provide it to \code{login_server()} +#' @param output_file path to new 'SQLite' database. After creation you need to provide it to \code{login_server()} #' @importFrom DBI dbConnect #' @importFrom RSQLite SQLite dbExecute dbDisconnect #' @@ -35,10 +35,10 @@ create_sqlite_db <- function(output_file){ } -#' Function to create new empty googlesheet database +#' Function to create new empty 'googlesheet' database #' -#' @param name specify name for googlesheet. Defaults to random name. -#' @return id of the googlesheet. After creation you need to provide it to \code{login_server()}. +#' @param name specify name for 'googlesheet' file. Defaults to random name. +#' @return id of the 'googlesheet' file. After creation you need to provide it to \code{login_server()}. #' @import googlesheets4 #' #' @export diff --git a/R/login_server.R b/R/login_server.R index ae4dd40..2c6acd9 100644 --- a/R/login_server.R +++ b/R/login_server.R @@ -119,29 +119,25 @@ } } -#### main server module of the package - googlesheets version #### +#### main server module of the package #### #' @title Login server module #' @name login_server #' @description Shiny server module for the optional login/registration system #' #' This function creates a server module to handle other modules of the system: \code{login_UI()}, \code{password_reset_UI()} and \code{register_UI} #' -#' It uses database contained in googlesheet file on your gdrive or sqlite database locally to read and write data of the users. You need to create a googlesheet or sqlite database containing at least two sheets/tables with specific columns: -#' -#' - user_db with columns named: \code{timestamp}, \code{user_id}, \code{user_mail} and \code{user_pass} -#' -#' - reset_db with columns named: \code{timestamp}, \code{user_id}, \code{reset_code} +#' It uses database contained in 'googlesheet' file on your 'gdrive' or 'SQLite' database locally to read and write data of the users. You need to create a 'googlesheet' or 'SQLite' using \code{create_gsheet_db()} or \code{create_sqlite_db()} respectively. #' #' #' @param id the id of the module. Defaults to "login_system" for all of the modules contained within the package. If you plan to use serveral login systems inside your app or for any other reason need to change it, remember to keep consistent id for all elements of module. -#' @param db_method the character string containing chosen database container, either: \code{"gsheet"} (needing installation of \code{googlesheets4} package) or \code{"sqlite"} (needing installation of \code{DBI} and \code{RSQLite} packages) -#' @param mail_method the character string containing chosen method of sending emails, either: \code{"gmailr"} (needing installation of \code{gmailr} package) \code{"emayili"} (needing installation of \code{emayili} package) +#' @param db_method the character string containing chosen database container, either: \code{"gsheet"} (needing installation of 'googlesheets4' package) or \code{"sqlite"} (needing installation of 'DBI' and 'RSQLite' packages) +#' @param mail_method the character string containing chosen method of sending emails, either: \code{"gmailr"} (needing installation of 'gmailr' package) \code{"emayili"} (needing installation of 'emayili' package) #' @param appname the character string containing the name of your application (used in automatic e-mails for information purposes) #' @param appaddress the character value containing the web address of your application (used in automatic e-mails for information purposes) #' @param lang specifies the app used language. Accepts "en" or "pl". Defaults to "en" #' -#' @param gsheet_file the ID of your googlesheet holding the database. It is contained within URL address of your googlesheet (for: \code{db_method = "gsheet"}) -#' @param sqlite_db the path to your SQLite database (for: \code{db_method = "sqlite"}) +#' @param gsheet_file the ID of your 'googlesheet' file holding the database. It is contained within URL address of your googlesheet (for: \code{db_method = "gsheet"}) +#' @param sqlite_db the path to your 'SQLite' database (for: \code{db_method = "sqlite"}) #' #' @param gmailr_user your gmail address (for: \code{db_method = "gmailr"}) #' @param emayili_user your email address, also used as login to your email account (for: \code{db_method = "emayili"}) @@ -164,14 +160,14 @@ #' #' ## Authorization #' -#' - When using db_method of "gsheet" you need to authorize access to your google drive outside of the functions (using \code{googlesheets4:gs_auth} with default scopes: \code{"https://www.googleapis.com/auth/spreadsheets"}) +#' - When using db_method of "gsheet" you need to authorize access to your google drive outside of the functions (using \code{googlesheets4:gs_auth()} with default scopes: \code{"https://www.googleapis.com/auth/spreadsheets"}) #' - When using mail_method of "emayili" you need to allow "less secure apps" to use your mailbox -#' - When using mail_method of "gmailr" you need to authorize access to your gmail box by creating Oauth2 App on 'Google Cloud Platform' and passing it to \code{gmailr::gm_auth_configure} and allowing scopes: \code{"https://www.googleapis.com/auth/gmail.send"} +#' - When using mail_method of "gmailr" you need to authorize access to your gmail box by creating Oauth2 App on 'Google Cloud Platform' and passing it to \code{gmailr::gm_auth_configure()} and allowing scopes: \code{"https://www.googleapis.com/auth/gmail.send"} #' #' ## Security #' -#' - Both passwords and reset codes are hashed with the help of \code{scrypt} package for the extra security -#' - gmailr mail_method seems to be more secure if you intend to use gmail account to send emails. emayili is suggested only when using other mailboxes +#' - Both passwords and reset codes are hashed with the help of 'scrypt' package for the extra security +#' - gmailr mail_method seems to be more secure if you intend to use 'gmail' account to send emails. 'emayili' is suggested only when using other mailboxes. #' #' @seealso [login_UI()] for the login window in UI #' @seealso [password_reset_UI()] for the password reset window in UI @@ -213,7 +209,7 @@ login_server <- function(id = "login_system", if(length(find.package("googlesheets4", quiet = T)) == 0){ - stop("To use this method for database storage, please install googlesheets4 package: install.packages('googlesheets4')") + stop("To use this method for database storage, please install 'googlesheets4' package: install.packages('googlesheets4')") } @@ -221,7 +217,7 @@ login_server <- function(id = "login_system", if(length(find.package("RSQLite", quiet = T)) + length(find.package("DBI", quiet = T)) != 2){ - stop("To use this method for database storage, please install DBI and RSQLite packages: install.packages('DBI', 'RSQLite')") + stop("To use this method for database storage, please install 'DBI' and 'RSQLite' packages: install.packages('DBI', 'RSQLite')") } } else {stop("Valid methods for databases are 'sqlite' or 'gsheet'")} #### checking for mail sending method #### @@ -229,13 +225,13 @@ login_server <- function(id = "login_system", if(mail_method == "emayili"){ if(length(find.package("emayili", quiet = T)) == 0){ - stop("To use this email method, please install emayili package: install.packages('emayili')") + stop("To use this email method, please install 'emayili' package: install.packages('emayili')") } } else if(mail_method == "gmailr"){ if(length(find.package("gmailr", quiet = T)) == 0){ - stop("To use this email method, please install gmailr package: install.packages('gmailr')") + stop("To use this email method, please install 'gmailr' package: install.packages('gmailr')") } } else{stop("Valid mailing methods are 'gmailr' or 'emayili'")} diff --git a/examples/create_gsheet_db.R b/examples/create_gsheet_db.R index 14d351d..7b07046 100644 --- a/examples/create_gsheet_db.R +++ b/examples/create_gsheet_db.R @@ -2,8 +2,6 @@ if(googlesheets4::gs4_has_token()){ gsheet.id <- create_gsheet_db() -shiny.reglog:::.gsheet_get_db(gsheet.id) - # you can then pass 'gsheet.id' to you 'login_server' call # # login_server(db_method = "gsheet", diff --git a/examples/create_sqlite_db.R b/examples/create_sqlite_db.R index 5efaab8..85177a4 100644 --- a/examples/create_sqlite_db.R +++ b/examples/create_sqlite_db.R @@ -2,8 +2,6 @@ sqlite.path <- tempfile(fileext = "sqlite") create_sqlite_db(sqlite.path) -shiny.reglog:::.sqlite_get_db(sqlite.path) - # you can then pass 'sqlite.path' to you 'login_server' call # # login_server(db_method = "sqlite", diff --git a/examples/shinybase_sqlite_emayili/app.R b/examples/shinybase_sqlite_emayili/app.R index 0ea21d0..b7e4526 100644 --- a/examples/shinybase_sqlite_emayili/app.R +++ b/examples/shinybase_sqlite_emayili/app.R @@ -5,9 +5,6 @@ if(interactive()){ #### example of db_method = "sqlite" and mail_method = "emayili" -# gmailR and googlesheets configuration should be contained -# in external .R file, restricted to shiny user - library(shiny) library(shiny.reglog) diff --git a/man/create_gsheet_db.Rd b/man/create_gsheet_db.Rd index 92761b3..2a1b750 100644 --- a/man/create_gsheet_db.Rd +++ b/man/create_gsheet_db.Rd @@ -2,26 +2,24 @@ % Please edit documentation in R/database_creation.R \name{create_gsheet_db} \alias{create_gsheet_db} -\title{Function to create new empty googlesheet database} +\title{Function to create new empty 'googlesheet' database} \usage{ create_gsheet_db(name = NULL) } \arguments{ -\item{name}{specify name for googlesheet. Defaults to random name.} +\item{name}{specify name for 'googlesheet' file. Defaults to random name.} } \value{ -id of the googlesheet. After creation you need to provide it to \code{login_server()}. +id of the 'googlesheet' file. After creation you need to provide it to \code{login_server()}. } \description{ -Function to create new empty googlesheet database +Function to create new empty 'googlesheet' database } \examples{ if(googlesheets4::gs4_has_token()){ gsheet.id <- create_gsheet_db() -shiny.reglog:::.gsheet_get_db(gsheet.id) - # you can then pass 'gsheet.id' to you 'login_server' call # # login_server(db_method = "gsheet", diff --git a/man/create_sqlite_db.Rd b/man/create_sqlite_db.Rd index 74e1418..6a80cdb 100644 --- a/man/create_sqlite_db.Rd +++ b/man/create_sqlite_db.Rd @@ -2,23 +2,21 @@ % Please edit documentation in R/database_creation.R \name{create_sqlite_db} \alias{create_sqlite_db} -\title{Function to create new empty sqlite database} +\title{Function to create new empty 'SQLite' database} \usage{ create_sqlite_db(output_file) } \arguments{ -\item{output_file}{path to new sqlite database. After creation you need to provide it to \code{login_server()}} +\item{output_file}{path to new 'SQLite' database. After creation you need to provide it to \code{login_server()}} } \description{ -Function to create new empty sqlite database +Function to create new empty 'SQLite' database } \examples{ sqlite.path <- tempfile(fileext = "sqlite") create_sqlite_db(sqlite.path) -shiny.reglog:::.sqlite_get_db(sqlite.path) - # you can then pass 'sqlite.path' to you 'login_server' call # # login_server(db_method = "sqlite", diff --git a/man/login_server.Rd b/man/login_server.Rd index f691a36..df9ebc9 100644 --- a/man/login_server.Rd +++ b/man/login_server.Rd @@ -23,9 +23,9 @@ login_server( \arguments{ \item{id}{the id of the module. Defaults to "login_system" for all of the modules contained within the package. If you plan to use serveral login systems inside your app or for any other reason need to change it, remember to keep consistent id for all elements of module.} -\item{db_method}{the character string containing chosen database container, either: \code{"gsheet"} (needing installation of \code{googlesheets4} package) or \code{"sqlite"} (needing installation of \code{DBI} and \code{RSQLite} packages)} +\item{db_method}{the character string containing chosen database container, either: \code{"gsheet"} (needing installation of 'googlesheets4' package) or \code{"sqlite"} (needing installation of 'DBI' and 'RSQLite' packages)} -\item{mail_method}{the character string containing chosen method of sending emails, either: \code{"gmailr"} (needing installation of \code{gmailr} package) \code{"emayili"} (needing installation of \code{emayili} package)} +\item{mail_method}{the character string containing chosen method of sending emails, either: \code{"gmailr"} (needing installation of 'gmailr' package) \code{"emayili"} (needing installation of 'emayili' package)} \item{appname}{the character string containing the name of your application (used in automatic e-mails for information purposes)} @@ -33,9 +33,9 @@ login_server( \item{lang}{specifies the app used language. Accepts "en" or "pl". Defaults to "en"} -\item{gsheet_file}{the ID of your googlesheet holding the database. It is contained within URL address of your googlesheet (for: \code{db_method = "gsheet"})} +\item{gsheet_file}{the ID of your 'googlesheet' file holding the database. It is contained within URL address of your googlesheet (for: \code{db_method = "gsheet"})} -\item{sqlite_db}{the path to your SQLite database (for: \code{db_method = "sqlite"})} +\item{sqlite_db}{the path to your 'SQLite' database (for: \code{db_method = "sqlite"})} \item{gmailr_user}{your gmail address (for: \code{db_method = "gmailr"})} @@ -61,11 +61,7 @@ Shiny server module for the optional login/registration system This function creates a server module to handle other modules of the system: \code{login_UI()}, \code{password_reset_UI()} and \code{register_UI} -It uses database contained in googlesheet file on your gdrive or sqlite database locally to read and write data of the users. You need to create a googlesheet or sqlite database containing at least two sheets/tables with specific columns: -\itemize{ -\item user_db with columns named: \code{timestamp}, \code{user_id}, \code{user_mail} and \code{user_pass} -\item reset_db with columns named: \code{timestamp}, \code{user_id}, \code{reset_code} -} +It uses database contained in 'googlesheet' file on your 'gdrive' or 'SQLite' database locally to read and write data of the users. You need to create a 'googlesheet' or 'SQLite' using \code{create_gsheet_db()} or \code{create_sqlite_db()} respectively. } \details{ The module logic creates a \code{reactiveValues()} object with loaded database of users and reset codes stored in \code{session$userData}. It allows to cut the reading from database to only one read per loading of the app - unfortunately it makes the app run slowly if the database of users gets very long. @@ -75,16 +71,16 @@ Registration of new account mails the confirmation e-mail to the end user on pro Provided e-mail is needed for password reset: 10 digits code is generated and mailed to the user to confirm its identity. Reset code remains valid for 24 hours. \subsection{Authorization}{ \itemize{ -\item When using db_method of "gsheet" you need to authorize access to your google drive outside of the functions (using \code{googlesheets4:gs_auth} with default scopes: \code{"https://www.googleapis.com/auth/spreadsheets"}) +\item When using db_method of "gsheet" you need to authorize access to your google drive outside of the functions (using \code{googlesheets4:gs_auth()} with default scopes: \code{"https://www.googleapis.com/auth/spreadsheets"}) \item When using mail_method of "emayili" you need to allow "less secure apps" to use your mailbox -\item When using mail_method of "gmailr" you need to authorize access to your gmail box by creating Oauth2 App on 'Google Cloud Platform' and passing it to \code{gmailr::gm_auth_configure} and allowing scopes: \code{"https://www.googleapis.com/auth/gmail.send"} +\item When using mail_method of "gmailr" you need to authorize access to your gmail box by creating Oauth2 App on 'Google Cloud Platform' and passing it to \code{gmailr::gm_auth_configure()} and allowing scopes: \code{"https://www.googleapis.com/auth/gmail.send"} } } \subsection{Security}{ \itemize{ -\item Both passwords and reset codes are hashed with the help of \code{scrypt} package for the extra security -\item gmailr mail_method seems to be more secure if you intend to use gmail account to send emails. emayili is suggested only when using other mailboxes +\item Both passwords and reset codes are hashed with the help of 'scrypt' package for the extra security +\item gmailr mail_method seems to be more secure if you intend to use 'gmail' account to send emails. 'emayili' is suggested only when using other mailboxes. } } } @@ -96,9 +92,6 @@ if(interactive()){ #### example of db_method = "sqlite" and mail_method = "emayili" -# gmailR and googlesheets configuration should be contained -# in external .R file, restricted to shiny user - library(shiny) library(shiny.reglog)