login register
This commit is contained in:
@@ -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");
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user