From 4e825cc4d33b5d0f56b1907a6ac901eb9af14f15 Mon Sep 17 00:00:00 2001 From: Puyodead1 Date: Mon, 8 Jul 2024 21:23:41 -0400 Subject: [PATCH 1/3] fix `verify_email` template --- assets/email_templates/verify_email.html | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/assets/email_templates/verify_email.html b/assets/email_templates/verify_email.html index 109fc4aa..cbd94280 100644 --- a/assets/email_templates/verify_email.html +++ b/assets/email_templates/verify_email.html @@ -69,7 +69,7 @@ > {emailVerificationUrl}{actionUrl} From 629451bbfd9698975bdb95dce4f3152bbdb3893c Mon Sep 17 00:00:00 2001 From: Puyodead1 Date: Mon, 8 Jul 2024 22:10:50 -0400 Subject: [PATCH 2/3] fix incorrect error field --- src/api/routes/auth/verify/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/api/routes/auth/verify/index.ts b/src/api/routes/auth/verify/index.ts index 49f74277..32c3f305 100644 --- a/src/api/routes/auth/verify/index.ts +++ b/src/api/routes/auth/verify/index.ts @@ -85,7 +85,7 @@ router.post( user = userTokenData.user; } catch { throw FieldErrors({ - password: { + token: { message: req.t("auth:password_reset.INVALID_TOKEN"), code: "INVALID_TOKEN", }, From bc432a4325644eb1e5040b47ed05eda699bd404f Mon Sep 17 00:00:00 2001 From: Puyodead1 Date: Mon, 8 Jul 2024 22:30:41 -0400 Subject: [PATCH 3/3] add email verification page --- .../email_templates/new_login_location.html | 145 +++++++++-------- assets/email_templates/password_changed.html | 4 +- .../password_reset_request.html | 125 ++++++++------- assets/email_templates/phone_removed.html | 4 +- assets/email_templates/verify_email.html | 9 +- assets/public/verify.html | 147 ++++++++++++++++++ flake.lock | Bin 1497 -> 1305 bytes src/api/Server.ts | 18 ++- src/util/util/email/index.ts | 3 +- 9 files changed, 323 insertions(+), 132 deletions(-) create mode 100644 assets/public/verify.html diff --git a/assets/email_templates/new_login_location.html b/assets/email_templates/new_login_location.html index f1c5f8c5..b8c4a4fb 100644 --- a/assets/email_templates/new_login_location.html +++ b/assets/email_templates/new_login_location.html @@ -1,76 +1,87 @@ - + + + + + + + Verify {instanceName} Login from New Location - - - - - - Verify {instanceName} Login from New Location + + - .ExternalClass { - width: 100%; - } - - - - -
- Branding + Branding -
+
-

+

- Hey {userUsername}, -

-

- It looks like someone tried to log into your {instanceName} - account from a new location. If this is you, follow the link - below to authorize logging in from this location on your - account. If this isn't you, we suggest changing your - password as soon as possible. -

-

- IP Address: {ipAddress} -
- Location: {locationCity}, {locationRegion}, - {locationCountryName} -

-
-
+ Hey {userUsername}, +

+

+ It looks like someone tried to log into your {instanceName} + account from a new location. If this is you, follow the link + below to authorize logging in from this location on your + account. If this isn't you, we suggest changing your + password as soon as possible. +

+

+ IP Address: {ipAddress} +
+ Location: {locationCity}, {locationRegion}, + {locationCountryName} +

+
+ -
-
Verify Login +
+
+
-

- Alternatively, you can directly paste this link into - your browser: -

- {actionUrl} + " + > +

+ Alternatively, you can directly paste this link into + your browser: +

+ {actionUrl} +
-
- - + diff --git a/assets/email_templates/password_changed.html b/assets/email_templates/password_changed.html index d0426279..7d368a0a 100644 --- a/assets/email_templates/password_changed.html +++ b/assets/email_templates/password_changed.html @@ -1,4 +1,4 @@ - + @@ -22,7 +22,7 @@ -
+
Branding + + + + + + + Password Reset Request for {instanceName} - - - - - - Password Reset Request for {instanceName} + + - .ExternalClass { - width: 100%; - } - - - - -
- Branding + Branding -
+
-

+

- Hey {userUsername}, -

-

- Your {instanceName} password can be reset by clicking the - button below. If you did not request a new password, please - ignore this email. -

-
-
+ Hey {userUsername}, +

+

+ Your {instanceName} password can be reset by clicking the + button below. If you did not request a new password, please + ignore this email. +

+
+ -
-
-

- Alternatively, you can directly paste this link into - your browser: -

- {actionUrl} + " + >Reset Password +
+
+
+

+ Alternatively, you can directly paste this link into + your browser: +

+ {actionUrl} +
-
- - + diff --git a/assets/email_templates/phone_removed.html b/assets/email_templates/phone_removed.html index 7cc552e9..bcbc8f18 100644 --- a/assets/email_templates/phone_removed.html +++ b/assets/email_templates/phone_removed.html @@ -1,4 +1,4 @@ - + @@ -22,7 +22,7 @@ -
+
Branding + @@ -22,7 +22,7 @@ -
+ diff --git a/assets/public/verify.html b/assets/public/verify.html new file mode 100644 index 00000000..c70d7709 --- /dev/null +++ b/assets/public/verify.html @@ -0,0 +1,147 @@ + + + + + + + Spacebar Server + + + + + + + + + +
+ Spacebar Logo + +
+

Verifying your email

+

Please wait...

+
+
+ + + + diff --git a/flake.lock b/flake.lock index ae5e8b23070de1f0618864a223c9a3c17f752ca5..844f26fa6bf673dc335b2aabc1e75e6c0d046c8c 100644 GIT binary patch literal 1305 zcmbVL+j5&Q5Pi14qNC?}tP2RKGkvgKx1QEZaj)~F!UY8fyO60p1Z6~lvC*{VrH}<#aYqhW!Q&u5+ zKM(dl=j$6tjLO(=tYw;gSCLoEK7un!@)+x^!HCPK@Rjc3nNE`?eA(AICDRYh4bm>w z)IyRtP$FKl;}lD1DMtyy2*FBf$HlZmEUHvDd7fYFN(WqYo@Bn~$0Dq68!hYJ|AW;K zd=1u$3u6C}23~K)6!UwUT<(F!ePLIjqZnKT< z7B|syIiR(FNb*jXPU(*0OO;JViNqE$pd$>WnahZ_G?5S!hnt*BA{`AL_^Flb`tFicl>`>KS{47a|&e~TyaXDYZ`wsl-@>pcv3G+$Vh4VpXYDD_^R zmPu(>lwr|%bzUSTs0BF{wV{q{Qo)fzltY9$(I#?)=@?vKtM_0?>}xE(lGPA=qxHDm XC2)50^sdW-2c6}964wq}$I-BL+kcBkbn$d%Ezv_v;VyTWjBt}+UX6D z6LQX*^FGPTU^q0=Ovu9cIDAn9HS}X1$x&5?@q18(!*pAfdPK#Fx+rDR1m8Z}9K+%3 zhtr1=5Tl%&{%!~3a6QLirGtdSW1`J`dTh*xI`GOalHur`ji;Sw30p=1rcoO3F}3eJ+>VteMg`tu4*v zQ!@*tk0i07hh5-7rqnWmJYWk~a7-~q!jrC#h@QEux3XCqgyp7kjf=iyc^HH#kJUfN z#-T)WlS4&80t4#Ks`49)k%&;ET6gj6b72Uy>(SQz~!cp)Tdb55_IE5Fkp?pD}r?VZO5_+^Lp_`@L7v^kDuZ&v8(%9s96ctD7KV z$#iBD+Kb7kQ`niNE{qNqA$?xOrSA9%7Qu-P7~u*H*S82~P(Z=}L<~y{y4-S2#*uyI pU5`Os-5X%}N3A^tkN&75oW0Z#U8v4egi7jeBA&5 diff --git a/src/api/Server.ts b/src/api/Server.ts index 472ab1d6..40d2b6dc 100644 --- a/src/api/Server.ts +++ b/src/api/Server.ts @@ -18,15 +18,15 @@ import { Config, - Email, - initDatabase, - initEvent, - JSONReplacer, - registerRoutes, - Sentry, - WebAuthn, ConnectionConfig, ConnectionLoader, + Email, + JSONReplacer, + Sentry, + WebAuthn, + initDatabase, + initEvent, + registerRoutes, } from "@spacebar/util"; import { Request, Response, Router } from "express"; import { Server, ServerOptions } from "lambert-server"; @@ -141,6 +141,10 @@ export class SpacebarServer extends Server { res.sendFile(path.join(PUBLIC_ASSETS_FOLDER, "index.html")), ); + app.get("/verify", (req, res) => + res.sendFile(path.join(PUBLIC_ASSETS_FOLDER, "verify.html")), + ); + this.app.use(ErrorHandler); Sentry.errorHandler(this.app); diff --git a/src/util/util/email/index.ts b/src/util/util/email/index.ts index d765f5ff..e3382794 100644 --- a/src/util/util/email/index.ts +++ b/src/util/util/email/index.ts @@ -141,8 +141,9 @@ export const Email: { */ generateLink: async function (type, id, email) { const token = (await generateToken(id, email)) as string; + // puyodead1: this is set to api endpoint because the verification page is on the server since no clients have one, and not all 3rd party clients will have one const instanceUrl = - Config.get().general.frontPage || "http://localhost:3001"; + Config.get().api.endpointPublic || "http://localhost:3001"; const link = `${instanceUrl}/${type}#token=${token}`; return link; },