- // TODO some of these could probably use the DB defaults
- let local_user_form = LocalUserForm {
- person_id: inserted_person.id,
- email: Some(data.email.to_owned()),
- password_encrypted: data.password.to_owned(),
- show_nsfw: Some(data.show_nsfw),
- show_bot_accounts: Some(true),
- theme: Some("browser".into()),
- default_sort_type: Some(SortType::Active as i16),
- default_listing_type: Some(ListingType::Subscribed as i16),
- lang: Some("browser".into()),
- show_avatars: Some(true),
- show_scores: Some(true),
- show_read_posts: Some(true),
- show_new_post_notifs: Some(false),
- send_notifications_to_email: Some(false),
- };
+ let local_user_form = LocalUserInsertForm::builder()
+ .person_id(inserted_person.id)
+ .email(data.email.as_deref().map(str::to_lowercase))
+ .password_encrypted(data.password.to_string())
+ .show_nsfw(Some(data.show_nsfw))
+ .accepted_application(accepted_application)
+ .default_listing_type(Some(local_site.default_post_listing_type))
+ .build();
+
+ let inserted_local_user = LocalUser::create(&mut context.pool(), &local_user_form).await?;
+
+ if local_site.site_setup && require_registration_application {
+ // Create the registration application
+ let form = RegistrationApplicationInsertForm {
+ local_user_id: inserted_local_user.id,
+ // We already made sure answer was not null above
+ answer: data.answer.clone().expect("must have an answer"),
+ };