From 784f2c976c776039e25781eb583cbbb86158c96b Mon Sep 17 00:00:00 2001 From: Alice Gaudon Date: Thu, 21 Jan 2021 17:12:59 +0100 Subject: [PATCH] Rename base_url setting to public_url --- config/default.json5 | 2 +- config/production.json5 | 4 ++-- src/Controller.ts | 2 +- src/auth/AuthGuard.ts | 2 +- src/auth/magic_link/MagicLinkController.ts | 2 +- src/helpers/BackendController.ts | 2 +- src/mail/Mail.ts | 2 +- 7 files changed, 8 insertions(+), 8 deletions(-) diff --git a/config/default.json5 b/config/default.json5 index 674b314..40779b3 100644 --- a/config/default.json5 +++ b/config/default.json5 @@ -8,7 +8,7 @@ verbose: true, db_level: "ERROR", }, - base_url: "http://localhost:4899", + public_url: "http://localhost:4899", public_websocket_url: "ws://localhost:4899", listen_addr: '127.0.0.1', port: 4899, diff --git a/config/production.json5 b/config/production.json5 index 20581fe..395b979 100644 --- a/config/production.json5 +++ b/config/production.json5 @@ -4,8 +4,8 @@ verbose: false, db_level: "ERROR", }, - base_url: "https://watch-my.stream", - public_websocket_url: "wss://watch-my.stream", + public_url: "https://swaf.example", + public_websocket_url: "wss://swaf.example", session: { cookie: { secure: true diff --git a/src/Controller.ts b/src/Controller.ts index 45107f9..bdcec20 100644 --- a/src/Controller.ts +++ b/src/Controller.ts @@ -38,7 +38,7 @@ export default abstract class Controller { } const queryStr = querystring.stringify(query); - return `${absolute ? config.get('base_url') : ''}${path}` + (queryStr.length > 0 ? '?' + queryStr : ''); + return `${absolute ? config.get('public_url') : ''}${path}` + (queryStr.length > 0 ? '?' + queryStr : ''); } private readonly router: Router = express.Router(); diff --git a/src/auth/AuthGuard.ts b/src/auth/AuthGuard.ts index f941414..09b735e 100644 --- a/src/auth/AuthGuard.ts +++ b/src/auth/AuthGuard.ts @@ -139,7 +139,7 @@ export default class AuthGuard { if (!user.isApproved()) { await new Mail(this.app.as(NunjucksComponent).getEnvironment(), PENDING_ACCOUNT_REVIEW_MAIL_TEMPLATE, { username: (await user.mainEmail.get())?.getOrFail('email'), - link: config.get('base_url') + Controller.route('accounts-approval'), + link: config.get('public_url') + Controller.route('accounts-approval'), }).send(config.get('app.contact_email')); } } diff --git a/src/auth/magic_link/MagicLinkController.ts b/src/auth/magic_link/MagicLinkController.ts index a0b7612..e3d047c 100644 --- a/src/auth/magic_link/MagicLinkController.ts +++ b/src/auth/magic_link/MagicLinkController.ts @@ -43,7 +43,7 @@ export default class MagicLinkController extends Controll // Send email await new Mail(app.as(NunjucksComponent).getEnvironment(), mailTemplate, Object.assign(data, { - link: `${config.get('base_url')}${Controller.route('magic_link', undefined, { + link: `${config.get('public_url')}${Controller.route('magic_link', undefined, { id: link.id, token: token, })}`, diff --git a/src/helpers/BackendController.ts b/src/helpers/BackendController.ts index 21958b1..e095d10 100644 --- a/src/helpers/BackendController.ts +++ b/src/helpers/BackendController.ts @@ -77,7 +77,7 @@ export default class BackendController extends Controller { if (email && email.email) { await new Mail(this.getApp().as(NunjucksComponent).getEnvironment(), ACCOUNT_REVIEW_NOTICE_MAIL_TEMPLATE, { approved: true, - link: config.get('base_url') + Controller.route('auth'), + link: config.get('public_url') + Controller.route('auth'), }).send(email.email); } diff --git a/src/mail/Mail.ts b/src/mail/Mail.ts index 1551321..363de88 100644 --- a/src/mail/Mail.ts +++ b/src/mail/Mail.ts @@ -105,7 +105,7 @@ export default class Mail { // Set data this.data.mail_subject = this.options.subject; this.data.mail_to = this.options.to; - this.data.mail_link = config.get('base_url') + + this.data.mail_link = config.get('public_url') + Controller.route('mail', [this.template.template], this.data); this.data.app = config.get('app');