Skip to content

Commit 4afff16

Browse files
authored
Fixing resend verification email. (#6470)
* Fixing resend verification email. * Clippy
1 parent 2d169d6 commit 4afff16

1 file changed

Lines changed: 12 additions & 3 deletions

File tree

crates/api/api/src/local_user/resend_verification_email.rs

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,22 @@ pub async fn resend_verification_email(
1212
Json(data): Json<ResendVerificationEmail>,
1313
context: Data<LemmyContext>,
1414
) -> LemmyResult<Json<SuccessResponse>> {
15-
let site_view = SiteView::read_local(&mut context.pool()).await?;
1615
let email = data.email.to_string();
1716

17+
// For security, errors are not returned.
18+
// https://github.com/LemmyNet/lemmy/issues/5277
19+
let _ = try_resend_verification_email(&email, &context).await;
20+
21+
Ok(Json(SuccessResponse::default()))
22+
}
23+
24+
async fn try_resend_verification_email(email: &str, context: &LemmyContext) -> LemmyResult<()> {
1825
// Fetch that email
19-
let local_user_view = LocalUserView::find_by_email(&mut context.pool(), &email).await?;
26+
let local_user_view = LocalUserView::find_by_email(&mut context.pool(), email).await?;
2027
check_local_user_valid(&local_user_view)?;
2128

29+
let site_view = SiteView::read_local(&mut context.pool()).await?;
30+
2231
send_verification_email_if_required(
2332
&site_view.local_site,
2433
&local_user_view,
@@ -27,5 +36,5 @@ pub async fn resend_verification_email(
2736
)
2837
.await?;
2938

30-
Ok(Json(SuccessResponse::default()))
39+
Ok(())
3140
}

0 commit comments

Comments
 (0)