fix: CI
This commit is contained in:
parent
32825ba9e1
commit
93e66f1236
1 changed files with 29 additions and 17 deletions
12
src/main.rs
12
src/main.rs
|
|
@ -73,6 +73,15 @@ async fn main() -> anyhow::Result<()> {
|
|||
.await?
|
||||
.unwrap_or(0);
|
||||
if user_count == 0 {
|
||||
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()?;
|
||||
|
|
@ -91,6 +100,9 @@ async fn main() -> anyhow::Result<()> {
|
|||
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