Create RegLog-valid database tables with googlesheets4
gsheet_tables_create.Rd
Create RegLog-valid database tables with googlesheets4
Usage
gsheet_tables_create(
account_name = "account",
reset_code_name = "reset_code",
use_log = FALSE,
log_name = "logs",
user_data = NULL,
hash_passwords = FALSE,
gsheet_ss = NULL,
gsheet_name = NULL,
verbose = TRUE
)
Arguments
- account_name
Name of the sheet for storing user accounts credentials. Defaults to 'account'. Mandatory spreadsheet.
- reset_code_name
Name of the sheet for storing generated password reset codes. Defaults to 'reset_code'. Mandatory table.
- use_log
Should the sheet for keeping RegLogServer logs be also created? Defaults to FALSE
- log_name
Name of the sheet for storing logs from RegLogServer object. Used only if
use_log = TRUE
. Defaults tologs
- user_data
If you wish to import existing user database, you can input data.frame with that table in this argument. It should contain columns: username, password, email. Defaults to NULL.
- hash_passwords
If you are importing table of users upon tables creation, you can also specify if the password should be hashed using
scrypt::hashPassword
. Defaults toFALSE
. If you have unhashed passwords in imported table, set this option toTRUE
.- gsheet_ss
ID of the googlesheet that you want to append created tables to. Defaults to
NULL
, which means creating new googlesheet.- gsheet_name
If
gsheet_ss = NULL
and new googlesheet will be generated, you can choose choose its name. If left at defaultNULL
, name will be generated randomly.- verbose
Boolean specific if the actions made by function should be printed back to the console. Defaults to
TRUE
. Don't affectgooglesheets4
generated messages. To silence them, useoptions(googlesheets4_quiet = TRUE)
in the script before.
Details
Created spreadsheets will have following structure:
account (default name)
username: character
password: character
email: character
create_time: character
update_time: character
reset_code (default name)
user_id: numeric
reset_code: character
used: numeric
create_time: character
update_time: character
logs (default name, optional)
time: character
session: character
direction: character
type: character
note: character
See also
Other RegLog databases:
DBI_tables_create()
,
mongo_tables_create()
Examples
if (googlesheets4::gs4_has_token()) {
library(shiny.reglog)
# mockup user data
user_data <-
data.frame(username = c("Whatever", "Hanuka", "Helsinki", "How_come"),
password = c("&f5*MSYj^niDt=V'3.[dyEX.C/", "%}&B[fs\\}5PKE@,*+V\\tx9\"at]",
"35z*ofW\\'G_8,@vCC`]~?e$Jm%", "s:;r_eLn?-D6;oA-=\"^R(-Ew<x"),
email = c("what@mil.com", "hehe@soso.so", "nider@what.no", "crazzz@simpsy.com"))
# create the tables and input the data (hashing the passwords in the process)
id <- gsheet_tables_create(user_data = user_data,
hash_passwords = TRUE,
verbose = FALSE)
# check generated googlesheet
googlesheets4::gs4_get(id)
# check the "account" sheet for credentials data
googlesheets4::read_sheet(id, "account")
# remove example googlesheets
googledrive::drive_trash(id)
}