add seed ability
This commit is contained in:
+5
-7
@@ -1,9 +1,10 @@
|
||||
mod db;
|
||||
mod hub;
|
||||
mod seed;
|
||||
mod views;
|
||||
|
||||
use std::time::Duration;
|
||||
use std::{env, future::Future, sync::Arc};
|
||||
use std::{env, future::Future, path::Path as FilePath, sync::Arc};
|
||||
|
||||
use argon2::{
|
||||
Argon2,
|
||||
@@ -255,6 +256,9 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
registration_mode,
|
||||
};
|
||||
|
||||
let seed_path = env::var("SEED_CONFIG").unwrap_or_else(|_| "seed.json".into());
|
||||
seed::seed_if_needed(&state.db, FilePath::new(&seed_path)).await;
|
||||
|
||||
let app = Router::new()
|
||||
.route("/", get(home))
|
||||
.route("/login", get(login_page).post(login))
|
||||
@@ -349,12 +353,6 @@ async fn register(
|
||||
form.invite.as_deref(),
|
||||
)));
|
||||
}
|
||||
if form.password.len() < 8 {
|
||||
return Ok(html_response(views::register_page(
|
||||
Some("Use a password with at least 8 characters."),
|
||||
form.invite.as_deref(),
|
||||
)));
|
||||
}
|
||||
|
||||
let password = form.password;
|
||||
let password_hash = tokio::task::spawn_blocking(move || hash_password(&password))
|
||||
|
||||
Reference in New Issue
Block a user