pub async fn make_admin(
db: &DB,
username: &str,
) -> Result<(), Box<dyn Error + Send + Sync>>Expand description
Promotes a user to admin status in the database
This function uses #[allow(dead_code)] due to rust providing a false positive warning
that this is dead code and not used, despite obvious usage in cli/server.rs -> called from cli/mod.rs
§Arguments
db- A reference to the database connectionusername- The username of the user to promote to admin
§Returns
Ok(())- If the user was successfully promoted to adminErr(Box<dyn Error>)- An error if the operation failed, such as if an admin already exists or if there was a database error
§Examples
use crate::db::DB;
use crate::db::queries::auth;
async fn example_make_admin(db: &DB) {
let username = "user_to_promote";
match auth::make_admin(db, username).await {
Ok(()) => println!("User promoted to admin successfully"),
Err(e) => eprintln!("Error promoting user to admin: {}", e),
}
}