This commit is contained in:
1 parent
984c7083a1
commit
7afdc4be97
29 files changed
+872
-33
No files matched your search
@@ -127,6 +127,9 @@ pub struct NewUser {
|
||||
pub email: Option<String>,
|
||||
#[serde(default)]
|
||||
pub groups: Vec<String>,
|
||||
/// Scheduling country (ISO 3166-1 alpha-2); defaults to CY like every new account.
|
||||
#[serde(default)]
|
||||
pub country: Option<String>,
|
||||
}
|
||||
|
||||
/// Creates a password account. `actor` is None only for trusted startup seeding; the request
|
||||
@@ -158,6 +161,19 @@ pub async fn create_password_user(
|
||||
let hash = service::hash_password(input.password).await?;
|
||||
let mut row = new_user_row(username.clone(), input.display_name, Some(hash));
|
||||
row.email = email;
|
||||
if let Some(country) = input
|
||||
.country
|
||||
.as_deref()
|
||||
.map(str::trim)
|
||||
.filter(|c| !c.is_empty())
|
||||
{
|
||||
let country = country.to_ascii_uppercase();
|
||||
ensure(
|
||||
crate::domain::valid_country(&country),
|
||||
crate::i18n::text("err_choose_a_valid_country_code_e79c72"),
|
||||
)?;
|
||||
row.country = country;
|
||||
}
|
||||
match row.clone().insert(&db.db).await {
|
||||
Ok(_) => {}
|
||||
Err(cot::db::DatabaseError::UniqueViolation) => {
|
||||
|
||||
Reference in new issue
Block a user