Fixed password hashing logic error

This commit is contained in:
Talha Qamar 2025-03-05 16:44:44 +05:00
parent 8bb227f48e
commit cdf0b7bd29
2 changed files with 8 additions and 3 deletions

View file

@ -9,6 +9,7 @@ pub struct Account {
creation_time: DateTime<Utc>,
// Donator role
premium: bool,
random: i64,
}
impl Account {
@ -17,12 +18,14 @@ impl Account {
user_id: UserID,
creation_time: DateTime<Utc>,
premium: bool,
random: i64,
) -> Self {
Self {
username,
user_id,
creation_time,
premium,
random,
}
}

View file

@ -59,15 +59,16 @@ impl Database {
}
pub fn get_user(&self, username: &str) -> Result<Account> {
let (user_id, creation_time, premium): (UserID, DateTime<Utc>, bool) =
let (user_id, creation_time, premium, random): (UserID, DateTime<Utc>, bool, i64) =
self.conn.query_row(
"SELECT username, user_id, creation_time, is_premium FROM users WHERE username=?1",
"SELECT username, user_id, creation_time, is_premium, random_value FROM users WHERE username=?1",
[username],
|row| {
let user_id = row.get(1)?;
let creation_time = row.get(2)?;
let premium = row.get(3)?;
Ok((user_id, creation_time, premium))
let random = row.get(4)?;
Ok((user_id, creation_time, premium, random))
},
)?;
Ok(Account::new(
@ -75,6 +76,7 @@ impl Database {
user_id,
creation_time,
premium,
random,
))
}