fix(service): fix register
This commit is contained in:
@@ -132,7 +132,15 @@ impl AuthService {
|
||||
.bind(&req.email)
|
||||
.bind(&hashed)
|
||||
.fetch_one(&mut *tx)
|
||||
.await?;
|
||||
.await
|
||||
.map_err(|e| {
|
||||
if let sqlx::Error::Database(db) = &e
|
||||
&& db.is_unique_violation()
|
||||
{
|
||||
return AppError::AlreadyExists("User already exists".into());
|
||||
}
|
||||
e.into()
|
||||
})?;
|
||||
|
||||
let user_count: i64 = sqlx::query_scalar("SELECT COUNT(1) FROM users WHERE tenant_id = $1")
|
||||
.bind(tenant_id)
|
||||
@@ -412,4 +420,3 @@ impl AuthService {
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user