pub struct User {
pub id: UserID,
pub username: String,
pub roles: Roles,
pub prefs: UserSettings,
pub picture: Option<i64>,
}
Fields§
§id: UserID
§username: String
§roles: Roles
§prefs: UserSettings
§picture: Option<i64>
Implementations§
source§impl User
impl User
sourcepub async fn get_all(
conn: &mut Transaction<'_>
) -> Result<Vec<Self>, DatabaseError>
pub async fn get_all(
conn: &mut Transaction<'_>
) -> Result<Vec<Self>, DatabaseError>
Method gets all entries from the table users.
pub async fn get_by_id(
conn: &mut Transaction<'_>,
uid: UserID
) -> Result<Self, DatabaseError>
pub async fn get(
conn: &mut Transaction<'_>,
username: &str
) -> Result<Self, DatabaseError>
sourcepub async fn authenticate(
conn: &mut Transaction<'_>,
uname: String,
pw: String
) -> Result<Self, DatabaseError>
pub async fn authenticate(
conn: &mut Transaction<'_>,
uname: String,
pw: String
) -> Result<Self, DatabaseError>
Method gets one entry from the table users based on the username supplied and password.
Arguments
uname
- username we wish to target and deletepw_hash
- hash of the password for the user we are trying to access
sourcepub async fn get_pass(
&self,
conn: &mut Transaction<'_>
) -> Result<String, DatabaseError>
pub async fn get_pass(
&self,
conn: &mut Transaction<'_>
) -> Result<String, DatabaseError>
sourcepub async fn delete(
conn: &mut Transaction<'_>,
uid: UserID
) -> Result<usize, DatabaseError>
pub async fn delete(
conn: &mut Transaction<'_>,
uid: UserID
) -> Result<usize, DatabaseError>
Method deletes a entry from the table users and returns the number of rows deleted. NOTE: Return should always be 1
Arguments
uname
- username we wish to target and delete
sourcepub async fn set_password(
&self,
conn: &mut Transaction<'_>,
password: String
) -> Result<usize, DatabaseError>
pub async fn set_password(
&self,
conn: &mut Transaction<'_>,
password: String
) -> Result<usize, DatabaseError>
Method resets the password for a user to a new password.
Arguments
&
- db &ectionpassword
- new password.