fix: require username, instead of username OR email

This commit is contained in:
JustTemmie 2025-07-13 16:20:03 +02:00
parent b87adf896f
commit d775723b7b
Signed by: justtemmie
SSH key fingerprint: SHA256:nBO+OwpTkd8LYhe38PIqdxmDvkIg9Vw2EbrRZM97dkU
2 changed files with 22 additions and 2 deletions

View file

@ -168,6 +168,26 @@ pub async fn user_uuid_from_identifier(
}
}
pub async fn user_uuid_from_username(
conn: &mut Conn,
identifier: &String,
) -> Result<Uuid, Error> {
if USERNAME_REGEX.is_match(identifier) {
use users::dsl;
let user_uuid = dsl::users
.filter(dsl::username.eq(identifier))
.select(dsl::uuid)
.get_result(conn)
.await?;
Ok(user_uuid)
} else {
Err(Error::BadRequest(
"Please provide a valid username".to_string(),
))
}
}
pub async fn global_checks(data: &Data, user_uuid: Uuid) -> Result<(), Error> {
if data.config.instance.require_email_verification {
let mut conn = data.pool.get().await?;