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 1fb38e0 commit ae4e42e
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ static USER_ID: Lazy<Arc<Mutex<i32>>> = Lazy::new(|| Arc::new(Mutex::new(0)));
lazy_static::lazy_static! {
static ref DB_CLIENT: Arc<Mutex<DatabaseConnectix>> = {
tokio::runtime::Runtime::new().unwrap().block_on(async {
return Arc::new(Mutex::new(DatabaseConnectix::new(std::env::var("DB_URL").unwrap())));
return Arc::new(Mutex::new(DatabaseConnectix::new(&std::env::var("DB_URL").unwrap()).unwrap()));
})
};
}
Expand Down
3 changes: 2 additions & 1 deletion src/user/auth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ impl DatabaseConnectix {

/// Gets a possible user id (if one exists) for a username.
pub async fn get_user_id(&self, username: &str) -> Result<i32, Error> {
let user: Option<Model> = query_as(
let mut user: Option<Model> = query_as(
"select max(id) from users where username=$1 limit 1;"
)
.bind(username)
Expand All @@ -33,6 +33,7 @@ impl DatabaseConnectix {
if user.is_none() {
Ok(1)
} else {
user=user.unwrap();
if user.unwrap().id == 9999 { return Err(anyhow!("username is taken")); }
Ok(user.unwrap().id+1)
}
Expand Down

0 comments on commit ae4e42e

Please sign in to comment.