|
|
|
@ -9,12 +9,10 @@ use lemmy_db_schema::{
|
|
|
|
|
source::{
|
|
|
|
|
email_verification::EmailVerification,
|
|
|
|
|
local_user::{LocalUser, LocalUserUpdateForm},
|
|
|
|
|
person::Person,
|
|
|
|
|
},
|
|
|
|
|
traits::Crud,
|
|
|
|
|
RegistrationMode,
|
|
|
|
|
};
|
|
|
|
|
use lemmy_db_views::structs::SiteView;
|
|
|
|
|
use lemmy_db_views::structs::{LocalUserView, SiteView};
|
|
|
|
|
use lemmy_utils::error::{LemmyErrorType, LemmyResult};
|
|
|
|
|
|
|
|
|
|
pub async fn verify_email(
|
|
|
|
@ -38,7 +36,7 @@ pub async fn verify_email(
|
|
|
|
|
};
|
|
|
|
|
let local_user_id = verification.local_user_id;
|
|
|
|
|
|
|
|
|
|
let local_user = LocalUser::update(&mut context.pool(), local_user_id, &form).await?;
|
|
|
|
|
LocalUser::update(&mut context.pool(), local_user_id, &form).await?;
|
|
|
|
|
|
|
|
|
|
EmailVerification::delete_old_tokens_for_local_user(&mut context.pool(), local_user_id).await?;
|
|
|
|
|
|
|
|
|
@ -46,12 +44,16 @@ pub async fn verify_email(
|
|
|
|
|
if site_view.local_site.registration_mode == RegistrationMode::RequireApplication
|
|
|
|
|
&& site_view.local_site.application_email_admins
|
|
|
|
|
{
|
|
|
|
|
let person = Person::read(&mut context.pool(), local_user.person_id)
|
|
|
|
|
let local_user = LocalUserView::read(&mut context.pool(), local_user_id)
|
|
|
|
|
.await?
|
|
|
|
|
.ok_or(LemmyErrorType::CouldntFindPerson)?;
|
|
|
|
|
|
|
|
|
|
send_new_applicant_email_to_admins(&person.name, &mut context.pool(), context.settings())
|
|
|
|
|
.await?;
|
|
|
|
|
send_new_applicant_email_to_admins(
|
|
|
|
|
&local_user.person.name,
|
|
|
|
|
&mut context.pool(),
|
|
|
|
|
context.settings(),
|
|
|
|
|
)
|
|
|
|
|
.await?;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Ok(Json(SuccessResponse::default()))
|
|
|
|
|