First auth fixes (#656)

This commit is contained in:
Geometrically
2023-07-13 19:50:42 -07:00
committed by GitHub
parent 0d88ff8dae
commit a89418e33b
3 changed files with 113 additions and 11 deletions

View File

@@ -22,21 +22,17 @@ pub fn send_email_raw(to: String, subject: String, body: String) -> Result<(), M
Some("Modrinth".to_string()),
Address::new("no-reply", "mail.modrinth.com")?,
))
.to(to.parse().unwrap())
.to(to.parse()?)
.subject(subject)
.header(ContentType::TEXT_HTML)
.body(body)
.unwrap();
.body(body)?;
let username = dotenvy::var("SMTP_USERNAME")?;
let password = dotenvy::var("SMTP_PASSWORD")?;
let host = dotenvy::var("SMTP_HOST")?;
let creds = Credentials::new(username, password);
let mailer = SmtpTransport::relay(&host)
.unwrap()
.credentials(creds)
.build();
let mailer = SmtpTransport::relay(&host)?.credentials(creds).build();
mailer.send(&email)?;

View File

@@ -1114,7 +1114,7 @@ pub async fn create_account_with_password(
.validate()
.map_err(|err| ApiError::InvalidInput(validation_errors_to_string(err, None)))?;
if check_turnstile_captcha(&req, &new_account.challenge).await? {
if !check_turnstile_captcha(&req, &new_account.challenge).await? {
return Err(ApiError::Turnstile);
}
@@ -1221,7 +1221,7 @@ pub async fn login_password(
redis: Data<deadpool_redis::Pool>,
login: web::Json<Login>,
) -> Result<HttpResponse, ApiError> {
if check_turnstile_captcha(&req, &login.challenge).await? {
if !check_turnstile_captcha(&req, &login.challenge).await? {
return Err(ApiError::Turnstile);
}
@@ -1590,7 +1590,7 @@ pub async fn reset_password_begin(
redis: Data<deadpool_redis::Pool>,
reset_password: web::Json<ResetPassword>,
) -> Result<HttpResponse, ApiError> {
if check_turnstile_captcha(&req, &reset_password.challenge).await? {
if !check_turnstile_captcha(&req, &reset_password.challenge).await? {
return Err(ApiError::Turnstile);
}