| RegLogServer | R Documentation |
RegLogServer is an R6 class to use for handling the whole backend of login and registration component of your shinyApp.
is_loggedreactiveVal containing logical indicating if the user is logged in
user_idreactiveVal containing character specifying the logged
user name. If the user is not logged in, it will consist
of uuid generated with uuid::UUIDgenerate
user_mailreactiveVal cantaining character string specifying the logged user mail. When not logged in, it contains NULL.
account_idreactiveVal caintaining integer specifying the logged
user account's id number: for SQL database it is equal to the value
contained withing id variable. For googlesheets database it is equal to
the row number - 1 (the header). If not logged, it contains NULL.
mail_messagereactiveVal containing most recent RegLogConnectorMessage received from mailConnector
messagereactiveVal containing most recent RegLogConnectorMessage received from dbConnector or generated by RegLogServer itself.
module_idcharacter storing ID for reglog_system module.
dbConnectorRegLogConnector object used for communication with the
database. Build-in children classes are RegLogDBIConnector and
RegLogGsheetConnector.
mailConnectorRegLogConnector object used for sending emails.
Built-in children classes are RegLogEmayiliConnector and
RegLogGmailrConnector.
loglist containing all messages send and received.
UI_list_loginreactiveVal holding the tagList of whole login UI.
UI_list_resetPassreactiveVal holding the tagList of whole resetPass UI.
UI_list_credsEditreactiveVal holding the tagList of whole credentioals edit UI.
UI_list_registerreactiveVal holding the tagList of whole register UI.
new()Initialize 'ReglogServer' moduleServer
RegLogServer$new( dbConnector, mailConnector, app_name = basename(getwd()), app_address = NULL, lang = "en", custom_txts = NULL, use_modals = TRUE, module_id = "login_system" )
dbConnectorobject of class RegLogConnector handling the reads
from and writes to database.
Two available in the package are RegLogDBIConnector and RegLogGsheetsConnector.
See their documentation for more information about usage and creation of
custom dbConnectors.
mailConnectorobject of class RegLogConnector handling the email
sending to the user for register confirmation and password reset.
Two available in the package are RegLogEmayiliConnector and
RegLogGmailrConnector. See their documentation for more information
about usage and creation of custom mailConnectors.
app_nameName of the app to refer during correspondence to users. Defaults to the name of working directory.
app_addressURL to refer to during correspondence to users. If left
at NULL, the URL will be parsed from session$clientData.
langcharacter specyfiyng which language to use for all texts generated in the UI. Defaults to 'en' for English. Currently 'pl' for Polish is also supported.
custom_txtsnamed list containing character strings with custom messages. Defaults to NULL, so all built-in strings will be used.
use_modalseither logical indicating if all (TRUE) or none (FALSE)
modalDialogs should be shown or character vector indicating which modals
should be shown. For more information see details.
module_idCharacter declaring the id of the module. Defaults to 'login_system'. Recommended to keep it that way, unless it would cause any namespace issues.
logout()Method logging out logged user
RegLogServer$logout()
get_logs()Method to receive all saved logs from the object in the form of single data.frame
RegLogServer$get_logs()
data.frame
clone()The objects of this class are cloneable with this method.
RegLogServer$clone(deep = FALSE)
deepWhether to make a deep clone.
# Run only in interactive session #
if (interactive()) {
library(shiny.reglog)
# for exemplary setup temporary SQLite database will be created
library("DBI")
library("RSQLite")
temp_sqlite <- tempfile(fileext = ".sqlite")
conn <- DBI::dbConnect(RSQLite::SQLite(),
dbname = temp_sqlite)
DBI_tables_create(conn)
DBI::dbDisconnect(conn)
# create minimalistic UI
ui <- navbarPage(
title = "RegLog system",
tabPanel("Register", RegLog_register_UI("custom_id")),
tabPanel("Login", RegLog_login_UI("custom_id")),
tabPanel("Credentials edit", RegLog_credsEdit_UI("custom_id")),
tabPanel("Password reset", RegLog_resetPass_UI("custom_id"))
)
# create server logic
server <- function(input, output, session) {
# create dbConnector with connection to the temporary SQLite database
dbConnector <- RegLogDBIConnector$new(
driver = RSQLite::SQLite(),
dbname = temp_sqlite)
# create mockup mailConnector
mailConnector <- RegLogConnector$new()
# create RegLogServer
RegLog <- RegLogServer$new(
dbConnector = dbConnector,
mailConnector = mailConnector,
## all arguments below are optional! ##
app_name = "RegLog example",
app_address = "https://reglogexample.com",
lang = "en",
# custom texts as a named list with strings
custom_txts = list(
user_id = "Name of the user",
register_success_t= "Congratulations - you have been registered in
successfully with RegLog system!"),
# use modals as a named list of FALSE to inhibit specific modal
use_modals = list(
login_success = FALSE),
# custom module id - provide the same to the UI elements!
module_id = "custom_id")
}
shinyApp(ui, server)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.