C# Class TShockAPI.DB.UserManager

UserManager - Methods for dealing with database users and other user functionality within TShock.
Show file Open project: NyxStudios/TShock Class Usage Examples

Public Methods

Method Description
AddUser ( User user ) : void

Adds a given username to the database

GetUser ( User user ) : User

Gets a user object by a user object.

GetUserByID ( int id ) : User

Gets a user object by their user ID.

GetUserByName ( string name ) : User

Gets a user object by name.

GetUserID ( string username ) : int

Gets the database ID of a given user object from the database.

GetUsers ( ) : List

Gets all users from the database.

GetUsersByName ( string username, bool notAtStart = false ) : List

Gets all users from the database with a username that starts with or contains username

RemoveUser ( User user ) : void

Removes a given username from the database

SetUserGroup ( User user, string group ) : void

Sets the group for a given username

SetUserPassword ( User user, string password ) : void

Sets the Hashed Password for a given username

SetUserUUID ( User user, string uuid ) : void

Sets the UUID for a given username

UpdateLogin ( User user ) : void

Updates the last accessed time for a database user to the current time.

UserManager ( IDbConnection db ) : System

Creates a UserManager object. During instantiation, this method will verify the table structure against the format below.

Private Methods

Method Description
LoadUserFromResult ( User user, QueryResult result ) : User

Fills out the fields of a User object with the results from a QueryResult object.

Method Details

AddUser() public method

Adds a given username to the database
public AddUser ( User user ) : void
user User User user
return void

GetUser() public method

Gets a user object by a user object.
public GetUser ( User user ) : User
user User The user object to search by.
return User

GetUserByID() public method

Gets a user object by their user ID.
public GetUserByID ( int id ) : User
id int The user's ID.
return User

GetUserByName() public method

Gets a user object by name.
public GetUserByName ( string name ) : User
name string The user's name.
return User

GetUserID() public method

Gets the database ID of a given user object from the database.
public GetUserID ( string username ) : int
username string The username of the user to query for.
return int

GetUsers() public method

Gets all users from the database.
public GetUsers ( ) : List
return List

GetUsersByName() public method

Gets all users from the database with a username that starts with or contains username
public GetUsersByName ( string username, bool notAtStart = false ) : List
username string Rough username search. "n" will match "n", "na", "nam", "name", etc
notAtStart bool If is not the first part of the username. If true then "name" would match "name", "username", "wordsnamewords", etc
return List

RemoveUser() public method

Removes a given username from the database
public RemoveUser ( User user ) : void
user User User user
return void

SetUserGroup() public method

Sets the group for a given username
public SetUserGroup ( User user, string group ) : void
user User User user
group string string group
return void

SetUserPassword() public method

Sets the Hashed Password for a given username
public SetUserPassword ( User user, string password ) : void
user User User user
password string string password
return void

SetUserUUID() public method

Sets the UUID for a given username
public SetUserUUID ( User user, string uuid ) : void
user User User user
uuid string string uuid
return void

UpdateLogin() public method

Updates the last accessed time for a database user to the current time.
public UpdateLogin ( User user ) : void
user User The user object to modify.
return void

UserManager() public method

Creates a UserManager object. During instantiation, this method will verify the table structure against the format below.
public UserManager ( IDbConnection db ) : System
db IDbConnection The database to connect to.
return System