account type is permanent and password registration is now working at checkout
This commit is contained in:
@@ -9,6 +9,7 @@ use crate::models::users;
|
||||
static welcome: Dir<'_> = include_dir!("src/mailers/auth/welcome");
|
||||
static forgot: Dir<'_> = include_dir!("src/mailers/auth/forgot");
|
||||
static magic_link: Dir<'_> = include_dir!("src/mailers/auth/magic_link");
|
||||
static set_password: Dir<'_> = include_dir!("src/mailers/auth/set_password");
|
||||
|
||||
#[allow(clippy::module_name_repetitions)]
|
||||
pub struct AuthMailer {}
|
||||
@@ -62,6 +63,31 @@ impl AuthMailer {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Sends a "set your password" email to a checkout-created account. Reuses
|
||||
/// the reset token; the link lands on the HTML `/set-password/{token}` page.
|
||||
///
|
||||
/// # Errors
|
||||
///
|
||||
/// When email sending is failed
|
||||
pub async fn send_set_password(ctx: &AppContext, user: &users::Model) -> Result<()> {
|
||||
Self::mail_template(
|
||||
ctx,
|
||||
&set_password,
|
||||
mailer::Args {
|
||||
to: user.email.to_string(),
|
||||
locals: json!({
|
||||
"name": user.name,
|
||||
"resetToken": user.reset_token,
|
||||
"domain": ctx.config.server.full_url()
|
||||
}),
|
||||
..Default::default()
|
||||
},
|
||||
)
|
||||
.await?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Sends a magic link authentication email to the user.
|
||||
///
|
||||
/// # Errors
|
||||
|
||||
10
src/mailers/auth/set_password/html.t
Normal file
10
src/mailers/auth/set_password/html.t
Normal file
@@ -0,0 +1,10 @@
|
||||
<html>
|
||||
|
||||
<body>
|
||||
Hey {{name}},
|
||||
Thanks for your order! We created an account for you. Set your password to finish, then you can track your orders:
|
||||
<a href="{{domain}}/set-password/{{resetToken}}">Set your password</a>
|
||||
If you didn't place this order, you can ignore this email.
|
||||
</body>
|
||||
|
||||
</html>
|
||||
1
src/mailers/auth/set_password/subject.t
Normal file
1
src/mailers/auth/set_password/subject.t
Normal file
@@ -0,0 +1 @@
|
||||
Set your password
|
||||
7
src/mailers/auth/set_password/text.t
Normal file
7
src/mailers/auth/set_password/text.t
Normal file
@@ -0,0 +1,7 @@
|
||||
Hey {{name}},
|
||||
|
||||
Thanks for your order! We created an account for you. Set your password to finish, then you can track your orders:
|
||||
|
||||
{{domain}}/set-password/{{resetToken}}
|
||||
|
||||
If you didn't place this order, you can ignore this email.
|
||||
Reference in New Issue
Block a user