mirror of
https://github.com/mCaptcha/mCaptcha.git
synced 2025-02-17 08:59:46 +03:00
email verification
This commit is contained in:
parent
c05888d648
commit
574efc2252
8 changed files with 41 additions and 11 deletions
8
.github/workflows/coverage.yml
vendored
8
.github/workflows/coverage.yml
vendored
|
@ -36,6 +36,14 @@ jobs:
|
|||
image: mcaptcha/cache
|
||||
ports:
|
||||
- 6379:6379
|
||||
smtp:
|
||||
image: maildev/maildev
|
||||
ports:
|
||||
- 10025:1025
|
||||
- 1080:1080
|
||||
options: >-
|
||||
--incoming-user admin
|
||||
--incoming-pass password
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
|
|
8
.github/workflows/linux.yml
vendored
8
.github/workflows/linux.yml
vendored
|
@ -37,6 +37,14 @@ jobs:
|
|||
image: mcaptcha/cache
|
||||
ports:
|
||||
- 6379:6379
|
||||
smtp:
|
||||
image: maildev/maildev
|
||||
ports:
|
||||
- 10025:1025
|
||||
- 1080:1080
|
||||
options: >-
|
||||
--incoming-user admin
|
||||
--incoming-pass password
|
||||
|
||||
|
||||
steps:
|
||||
|
|
|
@ -52,6 +52,7 @@ pool = 4
|
|||
[smtp]
|
||||
from = "admin@localhost"
|
||||
reply_to = "admin@localhost"
|
||||
url = "localhost:10025"
|
||||
url = "127.0.0.1"
|
||||
port = 10025
|
||||
username = "admin"
|
||||
password = "password"
|
||||
|
|
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 {
|
||||
|
|
|
@ -5,8 +5,6 @@
|
|||
<div class="details__row1">
|
||||
<p class="details__copyright-text">© mCaptcha developers</p>
|
||||
<ul class="details">
|
||||
<li class="details__copyright"></li>
|
||||
|
||||
<li class="details__item">
|
||||
<a class="details__link" href="<.= crate::PKG_HOMEPAGE .>">Homepage</a>
|
||||
</li>
|
||||
|
|
Loading…
Add table
Reference in a new issue