spsAccount {systemPipeShiny} | R Documentation |
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
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() # list all accounts db$accList() # add a new user db$accAdd('user2', '!admin12345') # list all accounts include password hash db$accList(include_pass = TRUE) # change password of an account db$accPassChange("user2", "$aaaaaaa") # check if pass changed db$accList(include_pass = TRUE) # change the role of from user to admin db$accRoleChange("user2", "admin") # check role change db$accList() # remove a user db$accRemove("user2") # check accounts again db$accList() # check if username and password matches db$accMatch(acc_name = "user", acc_pass = "user") # wrong pass db$accMatch("user", "user123") # also check if the user has the right role db$accMatch("user", "user", role = "user", match_role = TRUE) db$accMatch("user", "user", role = "admin", match_role = TRUE)