From cd07ff53100a5d70cf54e440eafeaec9ace81fe3 Mon Sep 17 00:00:00 2001 From: core Date: Sun, 19 Nov 2023 11:36:06 -0500 Subject: [PATCH] email sending & magic links (that work) --- trifid-api/config.toml | 6 +++--- .../migrations/2023-11-19-161415_create_magic_links/up.sql | 2 +- trifid-api/src/email.rs | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/trifid-api/config.toml b/trifid-api/config.toml index 7546671..0843af7 100644 --- a/trifid-api/config.toml +++ b/trifid-api/config.toml @@ -22,15 +22,15 @@ url = "postgres://postgres:postgres@localhost/trifid2" # (Required) The mail server to connect to server = "mail.e3t.cc" # (Required) The SMTP port to connect to. -port = 587 +port = 465 # (Required) The username to authenticate with. -username = "username" +username = "core" # (Required) The password to authenticate with. If set to %PASSWORD%, will be filled from the environment variable TRIFID_EMAIL_PASSWORD. password = "$PASSWORD$" # (Required) The "From Name" to send the email from from_name = "Trifid" # (Required) The address to send the email from -from_email = "trifid@e3t.cc" +from_email = "core@e3t.cc" # (Required) The email template to use. %TOKEN% will be replaced with the magic link token. template = "Click this link to sign in! http://localhost:5173/magic-link?magicLinkToken=%TOKEN%" # (Required) Should STARTTLS be used? diff --git a/trifid-api/migrations/2023-11-19-161415_create_magic_links/up.sql b/trifid-api/migrations/2023-11-19-161415_create_magic_links/up.sql index 65705e3..6146e82 100644 --- a/trifid-api/migrations/2023-11-19-161415_create_magic_links/up.sql +++ b/trifid-api/migrations/2023-11-19-161415_create_magic_links/up.sql @@ -1,5 +1,5 @@ CREATE TABLE magic_links ( id VARCHAR NOT NULL PRIMARY KEY, - user_id VARCHAR NOT NULL REFERENCES users(id), + user_id VARCHAR NOT NULL REFERENCES users(id) ON DELETE CASCADE, expires TIMESTAMP NOT NULL ); \ No newline at end of file diff --git a/trifid-api/src/email.rs b/trifid-api/src/email.rs index 80952f8..3ca4212 100644 --- a/trifid-api/src/email.rs +++ b/trifid-api/src/email.rs @@ -11,7 +11,7 @@ pub async fn send_email(token: &str, to_address: &str, config: &Config) -> Resul .text_body(config.email.template.replace("%TOKEN%", token)); let mut password = config.email.password.clone(); - if password == "%PASSWORD%" { + if password == "$PASSWORD$" { password = std::env::var("TRIFID_EMAIL_PASSWORD")?.clone(); }