Skip to content

Commit

Permalink
fix anyhow usage
Browse files Browse the repository at this point in the history
  • Loading branch information
callmeclover authored Apr 25, 2024
1 parent d99247e commit a23e097
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/user/auth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ impl DatabaseConnectix {

pub fn post_user(&mut self, username: &str, password: &str) -> Result<()> {
let data: Model = Model {
id: get_user_id(username)?,
id: self.get_user_id(username)?,
uuid: Uuid::new_v4(),
username,
password,
Expand All @@ -68,14 +68,16 @@ impl DatabaseConnectix {
.bind(data.id).bind(data.uuid).bind(data.username).bind(data.password).bind(data.glass)
.exectute(&mut self.connection)
.await?;
Ok(())
}

pub fn update_user(&mut self, username: &str, prev_username: &str, prev_id: i32) -> Result<()> {
let id = get_user_id(username)?;
let id = self.get_user_id(username)?;

let _ = sqlx::query("update users set username=$1, id=$2 where username=$3 and id=$4")
.bind(username).bind(id).bind(prev_username).bind(prev_id)
.exectute(&mut self.connection)
.await?;
Ok(())
}
}

0 comments on commit a23e097

Please sign in to comment.