Skip to content

Commit 9d1cdfa

Browse files
authored
Email templates fixes (#2659)
1 parent 8241f92 commit 9d1cdfa

File tree

4 files changed

+10
-1
lines changed

4 files changed

+10
-1
lines changed

crates/defguard_core/src/handlers/openid_flow.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -591,6 +591,7 @@ pub async fn secure_authorization(
591591
&mut conn,
592592
Some(&session_info.session.into()),
593593
&oauth2client.name,
594+
&session_info.user.username,
594595
)
595596
.await?;
596597
}

crates/defguard_mail/src/templates.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -327,10 +327,11 @@ pub async fn new_device_oidc_login_mail(
327327
conn: &mut PgConnection,
328328
session: Option<&SessionContext>,
329329
oauth2client_name: &str,
330+
username: &str,
330331
) -> Result<(), TemplateError> {
331332
let (mut tera, mut context) = get_base_tera_mjml(Context::new(), session, None, None)?;
332333

333-
let url = format!("{}me", Settings::url()?);
334+
let url = format!("{}user/{}", Settings::url()?, username);
334335
context.insert("oauth2client_name", &oauth2client_name);
335336
context.insert("profile_url", &url);
336337

crates/defguard_mail/src/tests.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -292,11 +292,13 @@ fn send_new_device_oidc_login_mail(_: PgPoolOptions, options: PgConnectOptions)
292292

293293
let mut conn = pool.begin().await.unwrap();
294294
let client_name = "RemoteApp";
295+
let username = "testuser";
295296
templates::new_device_oidc_login_mail(
296297
&env::var("SMTP_TO").unwrap(),
297298
&mut conn,
298299
None,
299300
client_name,
301+
username,
300302
)
301303
.await
302304
.unwrap();
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
UPDATE mail_context SET text = 'You''re receiving this email to configure a new desktop client'
2+
WHERE template = 'desktop-start' AND section = 'title' AND language_tag = 'en_US';
3+
4+
UPDATE mail_context SET text = 'You can deauthorize all applications that have access to your account from the web vault under (Profile > Authorized Apps).'
5+
WHERE template = 'new-device-oidc-login' AND section = 'subtitle' AND language_tag = 'en_US';

0 commit comments

Comments
 (0)