fix: CI
This commit is contained in:
parent
32825ba9e1
commit
93e66f1236
1 changed files with 29 additions and 17 deletions
46
src/main.rs
46
src/main.rs
|
|
@ -73,24 +73,36 @@ async fn main() -> anyhow::Result<()> {
|
|||
.await?
|
||||
.unwrap_or(0);
|
||||
if user_count == 0 {
|
||||
println!("\nNo users found. Create the first admin account.");
|
||||
print!("Username: ");
|
||||
io::stdout().flush()?;
|
||||
let mut username = String::new();
|
||||
io::stdin().read_line(&mut username)?;
|
||||
let username = username.trim().to_string();
|
||||
if username.is_empty() {
|
||||
anyhow::bail!("username cannot be empty");
|
||||
}
|
||||
let (username, password) = match (
|
||||
std::env::var("MERCURY_ADMIN_USER").ok().filter(|s| !s.is_empty()),
|
||||
std::env::var("MERCURY_ADMIN_PASSWORD").ok().filter(|s| !s.is_empty()),
|
||||
) {
|
||||
(Some(u), Some(p)) => {
|
||||
tracing::info!("creating first admin user from environment variables");
|
||||
(u, p)
|
||||
}
|
||||
_ => {
|
||||
println!("\nNo users found. Create the first admin account.");
|
||||
print!("Username: ");
|
||||
io::stdout().flush()?;
|
||||
let mut username = String::new();
|
||||
io::stdin().read_line(&mut username)?;
|
||||
let username = username.trim().to_string();
|
||||
if username.is_empty() {
|
||||
anyhow::bail!("username cannot be empty");
|
||||
}
|
||||
|
||||
print!("Password: ");
|
||||
io::stdout().flush()?;
|
||||
let mut password = String::new();
|
||||
io::stdin().read_line(&mut password)?;
|
||||
let password = password.trim().to_string();
|
||||
if password.is_empty() {
|
||||
anyhow::bail!("password cannot be empty");
|
||||
}
|
||||
print!("Password: ");
|
||||
io::stdout().flush()?;
|
||||
let mut password = String::new();
|
||||
io::stdin().read_line(&mut password)?;
|
||||
let password = password.trim().to_string();
|
||||
if password.is_empty() {
|
||||
anyhow::bail!("password cannot be empty");
|
||||
}
|
||||
(username, password)
|
||||
}
|
||||
};
|
||||
|
||||
let hash = bcrypt::hash(&password, bcrypt::DEFAULT_COST)?;
|
||||
sqlx::query(
|
||||
|
|
|
|||
Loading…
Reference in a new issue