diff --git a/api/config.dev.json b/api/config.dev.json index bab9b4e..93dbbb0 100644 --- a/api/config.dev.json +++ b/api/config.dev.json @@ -25,5 +25,7 @@ "refreshTokenExpirySeconds": 86400000, "title": "OpenBikeSensor" } - ] + ], + "imprintUrl": "https://example.com/imprint", + "privacyPolicyUrl": "https://example.com/privacy" } diff --git a/api/config.json.example b/api/config.json.example index 071e401..4d36c87 100644 --- a/api/config.json.example +++ b/api/config.json.example @@ -32,5 +32,7 @@ "refreshTokenExpirySeconds": 86400000, "title": "OpenBikeSensor" } - ] + ], + "imprintUrl": "https://example.com/imprint", + "privacyPolicyUrl": "https://example.com/privacy" } diff --git a/api/src/config.js b/api/src/config.js index a9315e5..90936f6 100644 --- a/api/src/config.js +++ b/api/src/config.js @@ -5,6 +5,9 @@ const configSchema = Joi.object({ jwtSecret: Joi.string().min(16).max(128).required(), cookieSecret: Joi.string().min(16).max(128).required(), + imprintUrl: Joi.string(), + privacyPolicyUrl: Joi.string(), + baseUrl: Joi.string().required(), mainFrontendUrl: Joi.string(), // optional diff --git a/api/src/routes/auth.js b/api/src/routes/auth.js index 12826f5..83ec0b5 100644 --- a/api/src/routes/auth.js +++ b/api/src/routes/auth.js @@ -52,6 +52,8 @@ function isValidScope(scope) { router.use((req, res, next) => { res.locals.user = req.user; res.locals.mainFrontendUrl = config.mainFrontendUrl; + res.locals.imprintUrl = config.imprintUrl; + res.locals.privacyPolicyUrl = config.privacyPolicyUrl; res.locals.baseUrl = baseUrl + '/'; next(); }); @@ -463,6 +465,10 @@ router email: Joi.string().email().required(), password: Joi.string().min(6).required(), confirmPassword: Joi.string().valid(Joi.ref('password')).required(), + + ...(config.privacyPolicyUrl ? { + acceptPrivacyPolicy: Joi.boolean().truthy().required(), + } : {}), }), ), wrapRoute(async (req, res) => { diff --git a/api/views/register.pug b/api/views/register.pug index 683c7ce..b5f0367 100644 --- a/api/views/register.pug +++ b/api/views/register.pug @@ -22,4 +22,17 @@ block content label(for="confirmPassword") Confirm Password input(id="confirmPassword", name="confirmPassword", type="password") + if privacyPolicyUrl + .field + label Privacy policy + + .ui.checkbox + input(id="acceptPrivacyPolicy", name="acceptPrivacyPolicy", type="checkbox", value="true") + label(for="acceptPrivacyPolicy") + | I have read and understood the + | + a(href=privacyPolicyUrl, target="_blank", rel="noreferrer") privacy policy + | + | and consent to the use of my data as described therein. + button.ui.button.primary(type="submit") Register