You've already forked authentication-service
mirror of
https://github.com/matrix-org/matrix-authentication-service.git
synced 2025-07-29 22:01:14 +03:00
Have a better error on registration if the username is already taken
This commit is contained in:
@ -476,6 +476,22 @@ pub async fn lookup_user_by_username(
|
||||
})
|
||||
}
|
||||
|
||||
pub async fn username_exists(
|
||||
executor: impl PgExecutor<'_>,
|
||||
username: &str,
|
||||
) -> Result<bool, sqlx::Error> {
|
||||
sqlx::query_scalar!(
|
||||
r#"
|
||||
SELECT EXISTS(
|
||||
SELECT 1 FROM users WHERE username = $1
|
||||
) AS "exists!"
|
||||
"#,
|
||||
username
|
||||
)
|
||||
.fetch_one(executor)
|
||||
.await
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
struct UserEmailLookup {
|
||||
user_email_id: i64,
|
||||
|
Reference in New Issue
Block a user