mirror of
https://github.com/mCaptcha/mCaptcha.git
synced 2026-02-11 18:15:39 +00:00
email verification
This commit is contained in:
22
src/data.rs
22
src/data.rs
@@ -19,6 +19,7 @@ use std::sync::Arc;
|
||||
|
||||
use actix::prelude::*;
|
||||
use argon2_creds::{Config, ConfigBuilder, PasswordPolicy};
|
||||
use lettre::transport::smtp::authentication::Mechanism;
|
||||
use lettre::{
|
||||
transport::smtp::authentication::Credentials, AsyncSmtpTransport, Tokio1Executor,
|
||||
};
|
||||
@@ -159,7 +160,7 @@ impl Data {
|
||||
.unwrap();
|
||||
|
||||
log::info!("Initializing credential manager");
|
||||
creds.init();
|
||||
//creds.init();
|
||||
log::info!("Initialized credential manager");
|
||||
|
||||
let data = Data {
|
||||
@@ -177,10 +178,21 @@ impl Data {
|
||||
let creds =
|
||||
Credentials::new(smtp.username.to_string(), smtp.password.to_string()); // "smtp_username".to_string(), "smtp_password".to_string());
|
||||
|
||||
let mailer: Mailer = AsyncSmtpTransport::<Tokio1Executor>::relay(&smtp.url) //"smtp.gmail.com")
|
||||
.unwrap()
|
||||
.credentials(creds)
|
||||
.build();
|
||||
let mailer: Mailer =
|
||||
AsyncSmtpTransport::<Tokio1Executor>::builder_dangerous(&smtp.url)
|
||||
.port(smtp.port)
|
||||
.credentials(creds)
|
||||
.authentication(vec![
|
||||
Mechanism::Login,
|
||||
Mechanism::Xoauth2,
|
||||
Mechanism::Plain,
|
||||
])
|
||||
.build();
|
||||
|
||||
// let mailer: Mailer = AsyncSmtpTransport::<Tokio1Executor>::relay(&smtp.url) //"smtp.gmail.com")
|
||||
// .unwrap()
|
||||
// .credentials(creds)
|
||||
// .build();
|
||||
Some(mailer)
|
||||
} else {
|
||||
None
|
||||
|
||||
@@ -102,9 +102,11 @@ mod tests {
|
||||
|
||||
#[actix_rt::test]
|
||||
async fn email_verification_works() {
|
||||
const TO_ADDR: &str = "Hello <newuser@localhost>";
|
||||
const TO_ADDR: &str = "Hello <realaravinth@localhost>";
|
||||
const VERIFICATION_LINK: &str = "https://localhost";
|
||||
let data = Data::new().await;
|
||||
verification(&data, TO_ADDR, VERIFICATION_LINK).await.unwrap();
|
||||
verification(&data, TO_ADDR, VERIFICATION_LINK)
|
||||
.await
|
||||
.unwrap();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ use log::info;
|
||||
mod api;
|
||||
mod data;
|
||||
mod docs;
|
||||
//mod email;
|
||||
mod email;
|
||||
mod errors;
|
||||
mod middleware;
|
||||
#[macro_use]
|
||||
|
||||
@@ -45,6 +45,7 @@ pub struct Smtp {
|
||||
pub url: String,
|
||||
pub username: String,
|
||||
pub password: String,
|
||||
pub port: u16,
|
||||
}
|
||||
|
||||
impl Server {
|
||||
|
||||
Reference in New Issue
Block a user