login register

This commit is contained in:
Priec
2026-06-18 17:19:04 +02:00
parent 7af0a48e92
commit ed607e3d27
17 changed files with 417 additions and 121 deletions

View File

@@ -1,4 +1,5 @@
use async_trait::async_trait;
use chrono::offset::Local;
use loco_rs::prelude::*;
use loco_rs::hash;
use sea_orm::{ActiveModelTrait, IntoActiveModel, Set};
@@ -30,10 +31,13 @@ impl Initializer for AdminSeeder {
let mut am = user.into_active_model();
am.password = Set(hash);
am.name = Set(name);
// The admin signs in through the same /login flow as everyone else,
// which requires a verified email — keep the seeded admin verified.
am.email_verified_at = Set(Some(Local::now().into()));
am.update(&ctx.db).await?;
tracing::info!(admin = %email, "admin password synced from .env");
} else {
users::Model::create_with_password(
let user = users::Model::create_with_password(
&ctx.db,
&RegisterParams {
email: email.clone(),
@@ -42,6 +46,10 @@ impl Initializer for AdminSeeder {
},
)
.await?;
// Auto-verify so the seeded admin can log in without an email round-trip.
let mut am = user.into_active_model();
am.email_verified_at = Set(Some(Local::now().into()));
am.update(&ctx.db).await?;
tracing::info!(admin = %email, "admin user seeded");
}