| RegLogServer {shiny.reglog} | R Documentation |
Login and registration moduleServer
Description
RegLogServer is an R6 class to use for handling the whole backend of login and registration component of your shinyApp.
Public fields
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::UUIDgenerateuser_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
idvariable. 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.
dbConnectorRegLogConnectorobject used for communication with the database. Build-in children classes areRegLogDBIConnectorandRegLogGsheetConnector.mailConnectorRegLogConnectorobject used for sending emails. Built-in children classes areRegLogEmayiliConnectorandRegLogGmailrConnector.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.
Methods
Public methods
Method new()
Initialize 'ReglogServer' moduleServer
Usage
RegLogServer$new( dbConnector, mailConnector, app_name = basename(getwd()), app_address = NULL, lang = "en", custom_txts = NULL, use_modals = TRUE, module_id = "login_system" )
Arguments
dbConnectorobject of class
RegLogConnectorhandling the reads from and writes to database. Two available in the package areRegLogDBIConnectorandRegLogGsheetsConnector. See their documentation for more information about usage and creation of custom dbConnectors.mailConnectorobject of class
RegLogConnectorhandling the email sending to the user for register confirmation and password reset. Two available in the package areRegLogEmayiliConnectorandRegLogGmailrConnector. 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.
Method logout()
Method logging out logged user
Usage
RegLogServer$logout()
Method get_logs()
Method to receive all saved logs from the object in the form of single data.frame
Usage
RegLogServer$get_logs()
Returns
data.frame
Method clone()
The objects of this class are cloneable with this method.
Usage
RegLogServer$clone(deep = FALSE)
Arguments
deepWhether to make a deep clone.
Examples
# 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)
}