Data about each user.
More...
#include <user.h>
◆ UserDataMap
◆ UserDataPair
◆ WritePriority
◆ user_write_priority_t
Enumerator |
---|
CRITICAL | User removal, privilege change, etc.
|
IMPORTANT | User creation.
|
NOMINAL | Sources, preferences, data attachments, etc.
|
TRIVIAL | Ratings.
|
◆ User() [1/3]
User::User |
( |
const std::string & |
username, |
|
|
const std::string & |
pass, |
|
|
bool |
encrypt = false |
|
) |
| |
Create a new user with the username and password.
Encrypt the password if requested (if not, it's already encrypted).
- Parameters
-
username | The user ID assigned the new user. |
pass | The password for the new user. |
encrypt | Whether to encrypt the password (user data restored from file will already be enciphered). |
◆ User() [2/3]
User::User |
( |
const User & |
| ) |
|
|
delete |
◆ User() [3/3]
◆ ~User()
◆ assignRank() [1/2]
bool User::assignRank |
( |
const std::string & |
newrank | ) |
|
Set a user's rank.
- Parameters
-
newrank | The text name of the rank to assign to the user. |
- Returns
- true if the text name is valid, false otherwise.
◆ assignRank() [2/2]
void User::assignRank |
( |
Rank |
newrank | ) |
|
Set a user's rank.
- Parameters
-
newrank | The rank enumerator to assign the user. |
◆ attachData()
Attach some data to a user.
The data is persisted with the user's record. On success, the pointer passed is stored in the user's record; it must not be freed. On failure, it is the responsibility of the caller to destroy it.
- Parameters
-
element | The data to attach. |
- Returns
- true on success, false on errror.
◆ authenticate() [1/2]
bool User::authenticate |
( |
const char * |
trypass | ) |
const |
Validate a user's credentials (username/password).
- Parameters
-
trypass | The password, unenciphered. It is enciphered and compared to the ciphered password on file. |
- Returns
- true on correct password, false otherwise.
◆ authenticate() [2/2]
bool User::authenticate |
( |
const std::string & |
trypass | ) |
const |
|
inline |
◆ changePassword()
bool User::changePassword |
( |
const std::string & |
old, |
|
|
const std::string & |
pass |
|
) |
| |
Change a user's password, authenticating the old one.
- Parameters
-
old | The user's old password, unenciphered. |
pass | The new password, unenciphered. |
- Returns
- true if the old password was valid, false otherwise.
◆ getData()
UserData::DataStore * User::getData |
( |
const std::string & |
datatype, |
|
|
const std::string & |
dataid = "" |
|
) |
| const |
Get data associated with a user.
- Parameters
-
datatype | The data type portion of the key. |
dataid | The ID portion of the key. |
◆ getPrivilege()
const Privilege User::getPrivilege |
( |
const std::string & |
privilege | ) |
|
|
static |
Translate a privilege to its enumerator.
- Parameters
-
privilege | The privilege name. |
- Returns
- The privilege enumerator.
- Exceptions
-
Invalid | argument if the privilege string is invalid. |
◆ getPrivilegeName()
const char * User::getPrivilegeName |
( |
Privilege |
privilege | ) |
|
|
static |
Translate a privilege enumerator to its text.
- Parameters
-
privilege | The privilege to lookup. |
- Returns
- The corresponding privilege name (string).
◆ getRank() [1/2]
const Rank User::getRank |
( |
const std::string & |
rank | ) |
|
|
static |
Translate a rank to its enumerator.
- Parameters
-
- Returns
- The rank enumerator.
- Exceptions
-
Invalid | argument if the rank string is invalid. |
◆ getRank() [2/2]
Rank User::getRank |
( |
void |
| ) |
const |
|
inline |
◆ getRankName() [1/2]
const char * User::getRankName |
( |
Rank |
rank | ) |
|
|
static |
Translate a rank enumerator to its text.
- Parameters
-
- Returns
- The corresponding rank name (string).
◆ getRankName() [2/2]
const char * User::getRankName |
( |
void |
| ) |
const |
Get the rank name for the current user.
- Returns
- Rank name (string) for the current user.
◆ getStartscriptUser()
User * User::getStartscriptUser |
( |
void |
| ) |
|
|
static |
Retrieve a user for processing the startup script.
- Returns
- A fake administrator user with all privileges.
◆ getVisitorRank()
static Rank User::getVisitorRank |
( |
| ) |
|
|
inlinestatic |
◆ havePrivilege()
bool User::havePrivilege |
( |
const Privilege |
priv | ) |
const |
◆ haveRank()
bool User::haveRank |
( |
const Rank |
minimum | ) |
const |
Determine if a user has a rank or better.
- Parameters
-
- Returns
- true if the user's rank is the minimum or better.
◆ online()
Determine if a user is online.
- Parameters
-
service | Reference to the service to be checked for logins. |
- Returns
- true if user has at least one authenticated connection.
◆ operator<() [1/2]
bool User::operator< |
( |
const std::string & |
other | ) |
|
|
inlineprotected |
◆ operator<() [2/2]
bool User::operator< |
( |
const User & |
other | ) |
|
|
inlineprotected |
◆ operator=() [1/2]
◆ operator=() [2/2]
◆ persist()
Prepare data for persistence.
- Returns
- A Parsnip Data object ready for serialization.
◆ reconstitute_user()
Create (restore) a user from a Parsnip object.
- Parameters
-
data | The root parsnip object containing the user information. |
- Returns
- A user structure.
- Exceptions
-
Throws | an exception if the object does not provide a minimally valid user, which is name, password, rank. |
◆ reconstituteUserData()
◆ removeData()
void User::removeData |
( |
const std::string & |
datatype, |
|
|
const std::string & |
dataid = "" |
|
) |
| |
Remove data associated with a user.
The data is freed if found.
- Parameters
-
datatype | The data type portion of the key. |
dataid | The ID portion of the key. |
◆ scheduleWrite()
◆ setPassword()
void User::setPassword |
( |
const std::string & |
pass | ) |
|
Change the password in a user's record.
- Parameters
-
◆ setPrivilege()
void User::setPrivilege |
( |
const Privilege |
priv, |
|
|
bool |
setting |
|
) |
| |
◆ setVisitorRank()
void User::setVisitorRank |
( |
const std::string & |
rank | ) |
|
|
static |
◆ shadow() [1/2]
static bool User::shadow |
( |
| ) |
|
|
inlinestatic |
◆ shadow() [2/2]
void User::shadow |
( |
bool |
mode | ) |
|
|
static |
◆ updateData()
void User::updateData |
( |
void |
| ) |
|
|
inline |
◆ username()
const std::string& User::username |
( |
void |
| ) |
const |
|
inline |
◆ UserManager
◆ data
Data sets attached to the user.
◆ name
◆ password
std::string User::password |
|
private |
◆ privileges
◆ rank
◆ shadow_mode
bool User::shadow_mode = false |
|
staticprivate |
◆ visitor_rank
Rank for users that have not authenticated.
◆ write_time
time_t User::write_time = 0 |
|
staticprivate |
The documentation for this class was generated from the following files: