avam-client and oauth2

This commit is contained in:
2024-10-17 00:56:02 +02:00
parent bfc5cbf624
commit f93eb3c429
50 changed files with 5674 additions and 277 deletions

View File

@@ -1,50 +0,0 @@
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);
};
}
}