Initiate this container at global level. Methods in this class can help admins to manage accounts in a SPS project.
It uses a SQLite database, by default is created inside config
directory on
SPS initialization.
You can use it to add/remove users, change user roles, change password, match/verify account, password, role.
A default user account "user", with password "user", and a default admin account "admin" with password "admin" are create for you.
For app deployment, PLEASE create your own accounts and DELETE the default ones.
systemPipeShiny::spsDb
-> systemPipeShiny::spsEncryption
-> spsaccount
Inherited methods
new()
initialize a new SPS account container
spsAccount$new()
accList()
list all accounts of the app. Returns a dataframe
spsAccount$accList(include_pass = FALSE, db_name = "config/sps.db")
include_pass
bool, include password hash column?
db_name
SPS database path
accAdd()
add an account to use the app
spsAccount$accAdd(acc_name, acc_pass, role = "user", db_name = "config/sps.db")
acc_name
string, account name
acc_pass
string, account password
role
string, what kind role is this user, one of "user", "admin"
db_name
SPS database path
accRemove()
remove an account
spsAccount$accRemove(acc_name, db_name = "config/sps.db")
acc_name
string, account name
db_name
SPS database path
accPassChange()
change password of an account
spsAccount$accPassChange(acc_name, acc_pass, db_name = "config/sps.db")
acc_name
string, account name
acc_pass
string, account new password
db_name
SPS database path
accRoleChange()
change the role of an account
spsAccount$accRoleChange(acc_name, role, db_name = "config/sps.db")
acc_name
string, account name
role
string, one of "user" or "admin"
db_name
SPS database path
accMatch()
Try to see if the account name exists and has the right password and role type, useful for login authentification.
spsAccount$accMatch( acc_name, acc_pass, role = "user", match_role = FALSE, db_name = "config/sps.db" )
acc_name
string, account name
acc_pass
string, account new password
role
string, one of "user" or "admin"
match_role
bool, also verify the account role type?
db_name
SPS database path
clone()
The objects of this class are cloneable with this method.
spsAccount$clone(deep = FALSE)
deep
Whether to make a deep clone.
dir.create("config", showWarnings = FALSE) spsOption("verbose", TRUE) spsOption("use_crayon", TRUE) # create a new container db <- spsAccount$new()#>#>#>#>db$createDb()#>#>#>#>#>#>#> [SPS-DANGER] 2021-09-18 02:42:27 Done, Db created at 'config/sps.db'. DO NOT share this file with others or upload to open access domains. #> [SPS-INFO] 2021-09-18 02:42:27 Key md5 bf0347e879706ba54826de2a38a9a0af# list all accounts db$accList()#>#>#> account role #> 1 admin admin #> 2 user user# add a new user db$accAdd('user2', '!admin12345')#>#># list all accounts include password hash db$accList(include_pass = TRUE)#>#>#> account pass #> 1 admin 20500faed327463d8b3d80cb40b9e514852be7b2c24ff0489e70ae65ed8d02e4 #> 2 user 9f5a4de3b28a5cd01441b4e8f471e092cf9e344251701c4085f6b74b4f05bf06 #> 3 user2 2dde4e35c2a65b09ac0ad04d64b301e078b929a19d37ff89d31676bea5059867 #> role #> 1 admin #> 2 user #> 3 user# change password of an account db$accPassChange("user2", "$aaaaaaa")#>#>#>#># check if pass changed db$accList(include_pass = TRUE)#>#>#> account pass #> 1 admin 20500faed327463d8b3d80cb40b9e514852be7b2c24ff0489e70ae65ed8d02e4 #> 2 user 9f5a4de3b28a5cd01441b4e8f471e092cf9e344251701c4085f6b74b4f05bf06 #> 3 user2 d9ec87e03b0a6e0559b0086641aa893e2015fda5ba9af8cff64de51e4ae47c50 #> role #> 1 admin #> 2 user #> 3 user# change the role of from user to admin db$accRoleChange("user2", "admin")#>#>#>#># check role change db$accList()#>#>#> account role #> 1 admin admin #> 2 user user #> 3 user2 admin# remove a user db$accRemove("user2")#>#>#>#># check accounts again db$accList()#>#>#> account role #> 1 admin admin #> 2 user user# check if username and password matches db$accMatch(acc_name = "user", acc_pass = "user")#>#> [1] TRUE# wrong pass db$accMatch("user", "user123")#>#> [1] FALSE# also check if the user has the right role db$accMatch("user", "user", role = "user", match_role = TRUE)#>#> [1] TRUEdb$accMatch("user", "user", role = "admin", match_role = TRUE)#>#> [1] FALSE