Skip to content

Commit

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

/// Gets a possible user id (if one exists) for a username.
pub fn get_user_id(&self, name: &str) -> Result<i32, Box<dyn Error>> {
if let Some(res) = self.connection.query_one("select max(id) from users where name=$1", &[&name])? {
if let Some(res) = self.connection.query_one("select max(id) from users where name=$1", &[&name]) {
if res.id == 9999 { return Err("username is taken".into()); }
Ok(res.id+1)
} else {
Expand All @@ -48,6 +48,6 @@ impl DatabaseConnectix {
self.connection.execute(
"INSERT INTO users (id, name, uuid, mod) VALUES ($1, $2, $3, $4)",
&[&id, &name, &uuid, &moderation_stats],
)?;
).expect("couldn't execute post_user query!");
}
}
5 changes: 3 additions & 2 deletions src/user/model.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use std::error::Error;
use rustrict::{Censor, Type};
use serde::{Serialize, Deserialize};
use postgres::types::Json;
use uuid::Uuid;

/// What am I?
Expand Down Expand Up @@ -54,8 +55,8 @@ impl From<User> for Model {
fn from(item: User) -> Self {
let (name, id) = item.name_split();
Self {
id,
name,
id.parse::<i32>().unwrap(),
name.to_string(),
uuid: item.uuid,
moderation_stats: item.glass
}
Expand Down

0 comments on commit d2b6125

Please sign in to comment.