From d96308ddccdef325603df8c364bd219e2c5d9e6b Mon Sep 17 00:00:00 2001 From: wodka Date: Thu, 18 Jul 2019 00:04:00 +0200 Subject: [PATCH] fix error if subdomain cannot be located and disable subdomain per default --- Dockerfile | 2 +- app/views/404.server.view.pug | 2 +- config/express.js | 46 +++++++++++++++++------------------ config/locales/de.json | 3 ++- config/locales/en.json | 3 ++- config/locales/es.json | 3 ++- config/locales/fr.json | 3 ++- config/locales/it.json | 5 ++-- config/locales/sv.json | 3 ++- 9 files changed, 38 insertions(+), 32 deletions(-) diff --git a/Dockerfile b/Dockerfile index 0dce360e..3bee94b1 100644 --- a/Dockerfile +++ b/Dockerfile @@ -21,7 +21,7 @@ ENV NODE_ENV=development \ BASE_URL=localhost \ SOCKET_PORT=20523 \ SIGNUP_DISABLED=FALSE \ - SUBDOMAINS_DISABLED=FALSE \ + SUBDOMAINS_DISABLED=TRUE \ ENABLE_CLUSTER_MODE=FALSE \ MAILER_EMAIL_ID=ohmyform@localhost \ MAILER_PASSWORD="" \ diff --git a/app/views/404.server.view.pug b/app/views/404.server.view.pug index a9370948..d2a1976a 100644 --- a/app/views/404.server.view.pug +++ b/app/views/404.server.view.pug @@ -5,4 +5,4 @@ block content div.row.valign h3.col-md-12.text-center=__('404_HEADER') div.col-md-4.col-md-offset-4 - div.col-md-12.text-center(style="padding-bottom: 50px;")=__('404_BODY', url) \ No newline at end of file + div.col-md-12.text-center(style="padding-bottom: 50px;")=__(custom || '404_BODY', url) diff --git a/config/express.js b/config/express.js index 26f71bf7..69a5fe53 100755 --- a/config/express.js +++ b/config/express.js @@ -87,6 +87,25 @@ module.exports = function(db) { app.locals.formJSFiles = config.getFormJavaScriptAssets(); app.locals.cssFiles = config.getCSSAssets(); + //Setup i18n + i18n.configure({ + locales: supportedLanguages, + directory: __dirname + '/locales', + defaultLocale: 'en', + cookie: 'userLang' + }); + + app.use(i18n.init); + + app.use(function(req, res, next) { + // express helper for natively supported engines + res.locals.__ = res.__ = function() { + return i18n.__.apply(req, arguments); + }; + + next(); + }); + app.use(function (req, res, next) { var urlPath; if(!config.subdomainsDisabled) { @@ -133,13 +152,13 @@ module.exports = function(db) { req.subdomains = null; // Error page return res.status(404).render('404', { - error: 'Page Does Not Exist' + custom: 'INVALID_SUB_DOMAIN' }); } if (user === null) { // Error page return res.status(404).render('404', { - error: 'Page Does Not Exist' + custom: 'INVALID_SUB_DOMAIN' }); } @@ -165,8 +184,8 @@ module.exports = function(db) { } }); - //Setup Prerender.io - app.use(require('prerender-node').set('prerenderToken', process.env.PRERENDER_TOKEN)); + //Setup Prerender.io + app.use(require('prerender-node').set('prerenderToken', process.env.PRERENDER_TOKEN)); // Passing the request url to environment locals @@ -188,25 +207,6 @@ module.exports = function(db) { level: 9 })); - //Setup i18n - i18n.configure({ - locales: supportedLanguages, - directory: __dirname + '/locales', - defaultLocale: 'en', - cookie: 'userLang' - }); - - app.use(i18n.init); - - app.use(function(req, res, next) { - // express helper for natively supported engines - res.locals.__ = res.__ = function() { - return i18n.__.apply(req, arguments); - }; - - next(); - }); - // Set template engine as defined in the config files app.engine('server.view.pug', consolidate.pug); diff --git a/config/locales/de.json b/config/locales/de.json index 0be3be9e..dfb6ed56 100644 --- a/config/locales/de.json +++ b/config/locales/de.json @@ -17,5 +17,6 @@ "RESET_PASSWORD_CONFIRMATION_EMAIL_PARAGRAPH_1": "Dies ist eine Höflichkeitsnachricht, um zu bestätigen, dass Ihr Passwort gerade geändert wurde.", "RESET_PASSWORD_REQUEST_EMAIL_PARAGRAPH_1": "Hier ist ein spezieller Link, mit dem Sie Ihr Passwort zurücksetzen können: Bitte beachten Sie, dass es innerhalb einer Stunde zu Ihrem Schutz abläuft:", "RESET_PASSWORD_REQUEST_EMAIL_LINK_TEXT": "Passwort zurücksetzen", - "RESET_PASSWORD_REQUEST_EMAIL_PARAGRAPH_2": "Falls Sie dies nicht gewünscht haben, ignorieren Sie bitte diese E-Mail und Ihr Passwort bleibt unverändert." + "RESET_PASSWORD_REQUEST_EMAIL_PARAGRAPH_2": "Falls Sie dies nicht gewünscht haben, ignorieren Sie bitte diese E-Mail und Ihr Passwort bleibt unverändert.", + "INVALID_SUB_DOMAIN": "Subdomain nicht gefunden" } diff --git a/config/locales/en.json b/config/locales/en.json index 20c478be..abc15c01 100644 --- a/config/locales/en.json +++ b/config/locales/en.json @@ -18,5 +18,6 @@ "RESET_PASSWORD_REQUEST_EMAIL_PARAGRAPH_1": "Here is a special link that will allow you to reset your password. Please note it will expire in one hour for your protection:", "RESET_PASSWORD_REQUEST_EMAIL_LINK_TEXT": "Reset Your Password", "RESET_PASSWORD_REQUEST_EMAIL_PARAGRAPH_2": "If you did not request this, please ignore this email and your password will remain unchanged.", - "RESET_PASSWORD_CONFIRMATION_EMAIL_BODY_1": "RESET_PASSWORD_CONFIRMATION_EMAIL_BODY_1" + "RESET_PASSWORD_CONFIRMATION_EMAIL_BODY_1": "RESET_PASSWORD_CONFIRMATION_EMAIL_BODY_1", + "INVALID_SUB_DOMAIN": "could not find subdomain" } diff --git a/config/locales/es.json b/config/locales/es.json index 51231f7b..626d41be 100644 --- a/config/locales/es.json +++ b/config/locales/es.json @@ -17,5 +17,6 @@ "RESET_PASSWORD_CONFIRMATION_EMAIL_PARAGRAPH_1": "Este es un mensaje de cortesía para confirmar que su contraseña acaba de cambiarse", "RESET_PASSWORD_REQUEST_EMAIL_PARAGRAPH_1": "Aquí hay un enlace especial que le permitirá restablecer su contraseña. Tenga en cuenta que caducará en una hora para su protección:", "RESET_PASSWORD_REQUEST_EMAIL_LINK_TEXT": "Restablecer su contraseña", - "RESET_PASSWORD_REQUEST_EMAIL_PARAGRAPH_2": "Si no lo solicitó, ignore este correo electrónico y su contraseña no cambiará". + "RESET_PASSWORD_REQUEST_EMAIL_PARAGRAPH_2": "Si no lo solicitó, ignore este correo electrónico y su contraseña no cambiará", + "INVALID_SUB_DOMAIN": "No se pudo encontrar el subdominio" } diff --git a/config/locales/fr.json b/config/locales/fr.json index 79805849..4bce6084 100644 --- a/config/locales/fr.json +++ b/config/locales/fr.json @@ -17,5 +17,6 @@ "RESET_PASSWORD_CONFIRMATION_EMAIL_PARAGRAPH_1": "Ceci est un message de courtoisie pour confirmer que votre mot de passe a été modifié.", "RESET_PASSWORD_REQUEST_EMAIL_PARAGRAPH_1": "Voici un lien spécial qui vous permettra de réinitialiser votre mot de passe. Veuillez noter qu'il expirera dans une heure pour votre protection :", "RESET_PASSWORD_REQUEST_EMAIL_LINK_TEXT": "Réinitialiser votre mot de passe", - "RESET_PASSWORD_REQUEST_EMAIL_PARAGRAPH_2": "Si vous ne l'avez pas demandé, veuillez ignorer cet e-mail et votre mot de passe restera inchangé." + "RESET_PASSWORD_REQUEST_EMAIL_PARAGRAPH_2": "Si vous ne l'avez pas demandé, veuillez ignorer cet e-mail et votre mot de passe restera inchangé.", + "INVALID_SUB_DOMAIN": "\nImpossible de trouver le sous-domaine" } diff --git a/config/locales/it.json b/config/locales/it.json index 7546f079..a3ec171d 100644 --- a/config/locales/it.json +++ b/config/locales/it.json @@ -14,8 +14,9 @@ "WELCOME_EMAIL_PARAGRAPH_2": "Speriamo che ti piace usare OhMyForm! Se hai problemi, non esitate a contattarci via", "WELCOME_EMAIL_SUBJECT": "Benvenuto a %s!", "WELCOME_EMAIL_TEXT": "Il tuo account è stato verificato correttamente.", - "RESET_PASSWORD_CONFIRMATION_EMAIL_PARAGRAPH_1": "Si tratta di un messaggio di cortesia per confermare che la password è stata appena modificata". + "RESET_PASSWORD_CONFIRMATION_EMAIL_PARAGRAPH_1": "Si tratta di un messaggio di cortesia per confermare che la password è stata appena modificata", "RESET_PASSWORD_REQUEST_EMAIL_PARAGRAPH_1": "Ecco un collegamento speciale che ti permetterà di reimpostare la tua password. Si prega di notare che scadrà in un'ora per la protezione:", "RESET_PASSWORD_REQUEST_EMAIL_LINK_TEXT": "Ripristina la tua password", - "RESET_PASSWORD_REQUEST_EMAIL_PARAGRAPH_2": "Se non l'hai richiesta, ignora questa email e la tua password rimane invariata." + "RESET_PASSWORD_REQUEST_EMAIL_PARAGRAPH_2": "Se non l'hai richiesta, ignora questa email e la tua password rimane invariata.", + "INVALID_SUB_DOMAIN": "Impossibile trovare sottodominio" } diff --git a/config/locales/sv.json b/config/locales/sv.json index cae6508d..73d362bb 100644 --- a/config/locales/sv.json +++ b/config/locales/sv.json @@ -18,5 +18,6 @@ "RESET_PASSWORD_REQUEST_EMAIL_PARAGRAPH_1": "Här är en speciell länk som kommer tillåta dig att återställa ditt lösenord. Vänligen notera att det kommer utgå om en timma för din säkerhet:", "RESET_PASSWORD_REQUEST_EMAIL_LINK_TEXT": "Återställ Ditt Lösenord", "RESET_PASSWORD_REQUEST_EMAIL_PARAGRAPH_2": "Om du inte begärde detta, vänligen ignorera detta meddelande och ditt lösenord kommer att förbli oförändrat.", - "RESET_PASSWORD_CONFIRMATION_EMAIL_BODY_1": "RESET_PASSWORD_CONFIRMATION_EMAIL_BODY_1" + "RESET_PASSWORD_CONFIRMATION_EMAIL_BODY_1": "RESET_PASSWORD_CONFIRMATION_EMAIL_BODY_1", + "INVALID_SUB_DOMAIN": "Det gick inte att hitta underdomänen" }