C# Класс TShockAPI.DB.User

A database user.
Показать файл Открыть проект Примеры использования класса

Защищенные свойства (Protected)

Свойство Тип Описание
HashTypes Func>.Dictionary

Открытые методы

Метод Описание
CreateBCryptHash ( string password ) : void

Creates a BCrypt hash for a user and stores it in this object.

CreateBCryptHash ( string password, int workFactor ) : void

Creates a BCrypt hash for a user and stores it in this object.

User ( ) : System

Default constructor for a user object; holds no data.

User ( string name, string pass, string uuid, string group, string registered, string last, string known ) : System

Constructor for the user object, assuming you define everything yourself.

VerifyPassword ( string password ) : bool

Verifies if a password matches the one stored in the database. If the password is stored in an unsafe hashing algorithm, it will be converted to BCrypt. If the password is stored using BCrypt, it will be re-saved if the work factor in the config is greater than the existing work factor with the new work factor.

Защищенные методы

Метод Описание
HashPassword ( byte bytes ) : string

Returns a hashed string for a given string based on the config file's hash algo

HashPassword ( string password ) : string

Returns a hashed string for a given string based on the config file's hash algo

UpgradePasswordToBCrypt ( string password ) : void

Upgrades a password to BCrypt, from an insecure hashing algorithm.

UpgradePasswordWorkFactor ( string password ) : void

Upgrades a password to the highest work factor available in the config.

Описание методов

CreateBCryptHash() публичный Метод

Creates a BCrypt hash for a user and stores it in this object.
public CreateBCryptHash ( string password ) : void
password string The plain text password to hash
Результат void

CreateBCryptHash() публичный Метод

Creates a BCrypt hash for a user and stores it in this object.
public CreateBCryptHash ( string password, int workFactor ) : void
password string The plain text password to hash
workFactor int The work factor to use in generating the password hash
Результат void

HashPassword() защищенный Метод

Returns a hashed string for a given string based on the config file's hash algo
protected HashPassword ( byte bytes ) : string
bytes byte bytes to hash
Результат string

HashPassword() защищенный Метод

Returns a hashed string for a given string based on the config file's hash algo
protected HashPassword ( string password ) : string
password string string to hash
Результат string

UpgradePasswordToBCrypt() защищенный Метод

Upgrades a password to BCrypt, from an insecure hashing algorithm.
protected UpgradePasswordToBCrypt ( string password ) : void
password string The raw user password (unhashed) to upgrade
Результат void

UpgradePasswordWorkFactor() защищенный Метод

Upgrades a password to the highest work factor available in the config.
protected UpgradePasswordWorkFactor ( string password ) : void
password string The raw user password (unhashed) to upgrade
Результат void

User() публичный Метод

Default constructor for a user object; holds no data.
public User ( ) : System
Результат System

User() публичный Метод

Constructor for the user object, assuming you define everything yourself.
public User ( string name, string pass, string uuid, string group, string registered, string last, string known ) : System
name string The user's name.
pass string The user's password hash.
uuid string The user's UUID.
group string The user's group name.
registered string The unix epoch for the registration date.
last string The unix epoch for the last access date.
known string The known IPs for the user, serialized as a JSON object
Результат System

VerifyPassword() публичный Метод

Verifies if a password matches the one stored in the database. If the password is stored in an unsafe hashing algorithm, it will be converted to BCrypt. If the password is stored using BCrypt, it will be re-saved if the work factor in the config is greater than the existing work factor with the new work factor.
public VerifyPassword ( string password ) : bool
password string The password to check against the user object.
Результат bool

Описание свойств

HashTypes защищенное свойство

A dictionary of hashing algorithms and an implementation object.
protected Dictionary> HashTypes
Результат Func>.Dictionary