spsAccount: SPS account management functions

spsAccountR Documentation

SPS account management functions

Description

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.

Super classes

systemPipeShiny::spsDb -> systemPipeShiny::spsEncryption -> spsaccount

Methods

Public methods

Inherited methods

Method new()

initialize a new SPS account container

Usage
spsAccount$new()

Method accList()

list all accounts of the app. Returns a dataframe

Usage
spsAccount$accList(include_pass = FALSE, db_name = "config/sps.db")
Arguments
include_pass

bool, include password hash column?

db_name

SPS database path


Method accAdd()

add an account to use the app

Usage
spsAccount$accAdd(acc_name, acc_pass, role = "user", db_name = "config/sps.db")
Arguments
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


Method accRemove()

remove an account

Usage
spsAccount$accRemove(acc_name, db_name = "config/sps.db")
Arguments
acc_name

string, account name

db_name

SPS database path


Method accPassChange()

change password of an account

Usage
spsAccount$accPassChange(acc_name, acc_pass, db_name = "config/sps.db")
Arguments
acc_name

string, account name

acc_pass

string, account new password

db_name

SPS database path


Method accRoleChange()

change the role of an account

Usage
spsAccount$accRoleChange(acc_name, role, db_name = "config/sps.db")
Arguments
acc_name

string, account name

role

string, one of "user" or "admin"

db_name

SPS database path


Method accMatch()

Try to see if the account name exists and has the right password and role type, useful for login authentification.

Usage
spsAccount$accMatch(
  acc_name,
  acc_pass,
  role = "user",
  match_role = FALSE,
  db_name = "config/sps.db"
)
Arguments
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


Method clone()

The objects of this class are cloneable with this method.

Usage
spsAccount$clone(deep = FALSE)
Arguments
deep

Whether to make a deep clone.

Examples

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)

systemPipeR/systemPipeS documentation built on Oct. 21, 2023, 12:18 p.m.