mirror of
https://github.com/mCaptcha/mCaptcha.git
synced 2026-02-11 10:05:41 +00:00
email verification
This commit is contained in:
8
.github/workflows/coverage.yml
vendored
8
.github/workflows/coverage.yml
vendored
@@ -36,6 +36,14 @@ jobs:
|
|||||||
image: mcaptcha/cache
|
image: mcaptcha/cache
|
||||||
ports:
|
ports:
|
||||||
- 6379:6379
|
- 6379:6379
|
||||||
|
smtp:
|
||||||
|
image: maildev/maildev
|
||||||
|
ports:
|
||||||
|
- 10025:1025
|
||||||
|
- 1080:1080
|
||||||
|
options: >-
|
||||||
|
--incoming-user admin
|
||||||
|
--incoming-pass password
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
|
|||||||
8
.github/workflows/linux.yml
vendored
8
.github/workflows/linux.yml
vendored
@@ -37,6 +37,14 @@ jobs:
|
|||||||
image: mcaptcha/cache
|
image: mcaptcha/cache
|
||||||
ports:
|
ports:
|
||||||
- 6379:6379
|
- 6379:6379
|
||||||
|
smtp:
|
||||||
|
image: maildev/maildev
|
||||||
|
ports:
|
||||||
|
- 10025:1025
|
||||||
|
- 1080:1080
|
||||||
|
options: >-
|
||||||
|
--incoming-user admin
|
||||||
|
--incoming-pass password
|
||||||
|
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
|
|||||||
@@ -52,6 +52,7 @@ pool = 4
|
|||||||
[smtp]
|
[smtp]
|
||||||
from = "admin@localhost"
|
from = "admin@localhost"
|
||||||
reply_to = "admin@localhost"
|
reply_to = "admin@localhost"
|
||||||
url = "localhost:10025"
|
url = "127.0.0.1"
|
||||||
|
port = 10025
|
||||||
username = "admin"
|
username = "admin"
|
||||||
password = "password"
|
password = "password"
|
||||||
|
|||||||
22
src/data.rs
22
src/data.rs
@@ -19,6 +19,7 @@ use std::sync::Arc;
|
|||||||
|
|
||||||
use actix::prelude::*;
|
use actix::prelude::*;
|
||||||
use argon2_creds::{Config, ConfigBuilder, PasswordPolicy};
|
use argon2_creds::{Config, ConfigBuilder, PasswordPolicy};
|
||||||
|
use lettre::transport::smtp::authentication::Mechanism;
|
||||||
use lettre::{
|
use lettre::{
|
||||||
transport::smtp::authentication::Credentials, AsyncSmtpTransport, Tokio1Executor,
|
transport::smtp::authentication::Credentials, AsyncSmtpTransport, Tokio1Executor,
|
||||||
};
|
};
|
||||||
@@ -159,7 +160,7 @@ impl Data {
|
|||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
log::info!("Initializing credential manager");
|
log::info!("Initializing credential manager");
|
||||||
creds.init();
|
//creds.init();
|
||||||
log::info!("Initialized credential manager");
|
log::info!("Initialized credential manager");
|
||||||
|
|
||||||
let data = Data {
|
let data = Data {
|
||||||
@@ -177,10 +178,21 @@ impl Data {
|
|||||||
let creds =
|
let creds =
|
||||||
Credentials::new(smtp.username.to_string(), smtp.password.to_string()); // "smtp_username".to_string(), "smtp_password".to_string());
|
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")
|
let mailer: Mailer =
|
||||||
.unwrap()
|
AsyncSmtpTransport::<Tokio1Executor>::builder_dangerous(&smtp.url)
|
||||||
.credentials(creds)
|
.port(smtp.port)
|
||||||
.build();
|
.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)
|
Some(mailer)
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
|
|||||||
@@ -102,9 +102,11 @@ mod tests {
|
|||||||
|
|
||||||
#[actix_rt::test]
|
#[actix_rt::test]
|
||||||
async fn email_verification_works() {
|
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";
|
const VERIFICATION_LINK: &str = "https://localhost";
|
||||||
let data = Data::new().await;
|
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 api;
|
||||||
mod data;
|
mod data;
|
||||||
mod docs;
|
mod docs;
|
||||||
//mod email;
|
mod email;
|
||||||
mod errors;
|
mod errors;
|
||||||
mod middleware;
|
mod middleware;
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
|
|||||||
@@ -45,6 +45,7 @@ pub struct Smtp {
|
|||||||
pub url: String,
|
pub url: String,
|
||||||
pub username: String,
|
pub username: String,
|
||||||
pub password: String,
|
pub password: String,
|
||||||
|
pub port: u16,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Server {
|
impl Server {
|
||||||
|
|||||||
@@ -5,8 +5,6 @@
|
|||||||
<div class="details__row1">
|
<div class="details__row1">
|
||||||
<p class="details__copyright-text">© mCaptcha developers</p>
|
<p class="details__copyright-text">© mCaptcha developers</p>
|
||||||
<ul class="details">
|
<ul class="details">
|
||||||
<li class="details__copyright"></li>
|
|
||||||
|
|
||||||
<li class="details__item">
|
<li class="details__item">
|
||||||
<a class="details__link" href="<.= crate::PKG_HOMEPAGE .>">Homepage</a>
|
<a class="details__link" href="<.= crate::PKG_HOMEPAGE .>">Homepage</a>
|
||||||
</li>
|
</li>
|
||||||
|
|||||||
Reference in New Issue
Block a user