You've already forked authentication-service
mirror of
https://github.com/matrix-org/matrix-authentication-service.git
synced 2025-08-09 04:22:45 +03:00
CLI subcommand to mark emails as verified
This commit is contained in:
@@ -15,7 +15,9 @@
|
||||
use argon2::Argon2;
|
||||
use clap::Parser;
|
||||
use mas_config::DatabaseConfig;
|
||||
use mas_storage::user::register_user;
|
||||
use mas_storage::user::{
|
||||
lookup_user_by_username, lookup_user_email, mark_user_email_as_verified, register_user,
|
||||
};
|
||||
use tracing::{info, warn};
|
||||
|
||||
use super::RootCommand;
|
||||
@@ -33,6 +35,9 @@ enum ManageSubcommand {
|
||||
|
||||
/// List active users
|
||||
Users,
|
||||
|
||||
/// Mark email address as verified
|
||||
VerifyEmail { username: String, email: String },
|
||||
}
|
||||
|
||||
impl ManageCommand {
|
||||
@@ -54,6 +59,20 @@ impl ManageCommand {
|
||||
SC::Users => {
|
||||
warn!("Not implemented yet");
|
||||
|
||||
Ok(())
|
||||
}
|
||||
SC::VerifyEmail { username, email } => {
|
||||
let config: DatabaseConfig = root.load_config()?;
|
||||
let pool = config.connect().await?;
|
||||
let mut txn = pool.begin().await?;
|
||||
|
||||
let user = lookup_user_by_username(&mut txn, username).await?;
|
||||
let email = lookup_user_email(&mut txn, &user, email).await?;
|
||||
let email = mark_user_email_as_verified(&mut txn, email).await?;
|
||||
|
||||
txn.commit().await?;
|
||||
info!(?email, "Email marked as verified");
|
||||
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user