Initial Commit

This commit is contained in:
2024-10-12 14:36:36 +02:00
commit bfc5cbf624
67 changed files with 10860 additions and 0 deletions

View File

@@ -0,0 +1,18 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>AVAM - Activate your Account</title>
</head>
<body>
<p>Thank you for joining Avii's Virtual Airline Manager.</p>
<p>Please click <a href="{{ activate_url }}" target="_BLANK">here</a> or go to <a href="{{ activate_url }}"
target="_BLANK">{{ activate_url }}</a> to activate your
account.</p>
</body>
</html>

View File

@@ -0,0 +1,3 @@
Thank you for joining Avii's Virtual Airline Manager.
Please go to {{ activate_url }} to activate your account.

View File

@@ -0,0 +1,17 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>AVAM - Reset Password Request</title>
</head>
<body>
<p>Reset Password</p>
<p>Please click <a href="{{ reset_url }}" target="_BLANK">here</a> or go to <a href="{{ reset_url }}"
target="_BLANK">{{ reset_url }}</a> to reset your password.</p>
</body>
</html>

View File

@@ -0,0 +1,3 @@
Password Reset
Please go to {{ reset_url }} to reset your password.

View File

@@ -0,0 +1,50 @@
use lettre::AsyncTransport;
use crate::domain::api::ports::UserNotifier;
use crate::domain::api::models::user::*;
use super::DangerousLettre;
impl UserNotifier for DangerousLettre {
async fn user_created(&self, user: &User, token: &ActivationToken) {
let mut context = tera::Context::new();
let url = format!("http://127.0.0.1:3000/auth/activate/{}", token); // Move base url to env
context.insert("activate_url", &url);
let to = format!("{}", user.email()).parse().unwrap();
let message = self
.template("user/created", "Welcome to AVAM!", &context, to)
.unwrap();
if let Err(e) = self.mailer.send(message).await {
eprintln!("{:#?}", e);
};
}
async fn forgot_password(&self, user: &User, token: &ForgotPasswordToken) {
let mut context = tera::Context::new();
let url = format!("http://127.0.0.1:3000/auth/reset/{}", token); // Move base url to env
context.insert("reset_url", &url);
let to = format!("{}", user.email()).parse().unwrap();
let message = self
.template(
"user/password_reset",
"Password reset request",
&context,
to,
)
.unwrap();
if let Err(e) = self.mailer.send(message).await {
eprintln!("{:#?}", e);
};
}
}