diff --git a/config_example.json b/config_example.json index 15370e0..8007146 100644 --- a/config_example.json +++ b/config_example.json @@ -93,6 +93,7 @@ "open_registration": true, "open_registration_web_toggle": false, "private_society": false, + "private_society_gate": "cloudflare", "paths": { "images": "/b", diff --git a/package-lock.json b/package-lock.json index 587e0da..8bc2c55 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10,6 +10,7 @@ "license": "MIT", "dependencies": { "@ruffle-rs/ruffle": "0.2.0-nightly.2026.4.21", + "cloudflare-error-page": "^0.1.0", "cuffeo": "git+https://git.lat/kibi/scuffeo.git", "flumm-fetch": "^1.0.1", "flummpress": "^2.0.5", @@ -55,12 +56,33 @@ "integrity": "sha512-/Ndrl68UQLhnCdsAzEXLMFuOR546o2qbYRqCglaNHbjXrwG1ayTcdwr3zkSGOGtGXDyR5X9nCFfnyG2AFJIsqg==", "license": "Apache-2.0" }, + "node_modules/async": { + "version": "3.2.6", + "resolved": "https://registry.npmjs.org/async/-/async-3.2.6.tgz", + "integrity": "sha512-htCUDlxyyCLMgaM3xXg0C0LW2xqfuQ6p05pCEIsXuyQ+a1koYKTuBMzRNwmybfLgvJDMd0r1LTn4+E0Ti6C2AA==", + "license": "MIT" + }, + "node_modules/balanced-match": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", + "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==", + "license": "MIT" + }, "node_modules/base-x": { "version": "5.0.1", "resolved": "https://registry.npmjs.org/base-x/-/base-x-5.0.1.tgz", "integrity": "sha512-M7uio8Zt++eg3jPj+rHMfCC+IuygQHHCOU+IYsVtik6FWjuYpVt/+MRKcgsAMHh8mMFAwnB+Bs+mTrFiXjMzKg==", "license": "MIT" }, + "node_modules/brace-expansion": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.1.0.tgz", + "integrity": "sha512-TN1kCZAgdgweJhWWpgKYrQaMNHcDULHkWwQIspdtjV4Y5aurRdZpjAqn6yX3FPqTA9ngHCc4hJxMAMgGfve85w==", + "license": "MIT", + "dependencies": { + "balanced-match": "^1.0.0" + } + }, "node_modules/bs58": { "version": "6.0.0", "resolved": "https://registry.npmjs.org/bs58/-/bs58-6.0.0.tgz", @@ -70,6 +92,18 @@ "base-x": "^5.0.0" } }, + "node_modules/cloudflare-error-page": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/cloudflare-error-page/-/cloudflare-error-page-0.1.0.tgz", + "integrity": "sha512-Eogslg+b+hcGjzjdD/DeDD5/Yet0U6eck49FVrkrbTBy9rLMWPMpWd4otIG+vDSmqc9GVxpuBYV7PjNv3wAm4A==", + "license": "MIT", + "dependencies": { + "ejs": "^3.1.10" + }, + "engines": { + "node": ">=18.0.0" + } + }, "node_modules/content-type": { "version": "1.0.5", "resolved": "https://registry.npmjs.org/content-type/-/content-type-1.0.5.tgz", @@ -93,6 +127,21 @@ "flumm-fetch": "^1.0.1" } }, + "node_modules/ejs": { + "version": "3.1.10", + "resolved": "https://registry.npmjs.org/ejs/-/ejs-3.1.10.tgz", + "integrity": "sha512-UeJmFfOrAQS8OJWPZ4qtgHyWExa088/MtK5UEyoJGFH67cDEXkZSviOiKRCZ4Xij0zxI3JECgYs3oKx+AizQBA==", + "license": "Apache-2.0", + "dependencies": { + "jake": "^10.8.5" + }, + "bin": { + "ejs": "bin/cli.js" + }, + "engines": { + "node": ">=0.10.0" + } + }, "node_modules/events": { "version": "3.3.0", "resolved": "https://registry.npmjs.org/events/-/events-3.3.0.tgz", @@ -102,6 +151,15 @@ "node": ">=0.8.x" } }, + "node_modules/filelist": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/filelist/-/filelist-1.0.6.tgz", + "integrity": "sha512-5giy2PkLYY1cP39p17Ech+2xlpTRL9HLspOfEgm0L6CwBXBTgsK5ou0JtzYuepxkaQ/tvhCFIJ5uXo0OrM2DxA==", + "license": "Apache-2.0", + "dependencies": { + "minimatch": "^5.0.1" + } + }, "node_modules/flumm-fetch": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/flumm-fetch/-/flumm-fetch-1.0.1.tgz", @@ -142,6 +200,23 @@ "integrity": "sha512-VLghIWNM6ELQzo7zwmcg0NmTVyWKYjvIeM83yjp0wRDTmUnrM678fQbcKBo6n2CJEF0szoG//ytg+TKla89ALQ==", "license": "MIT" }, + "node_modules/jake": { + "version": "10.9.4", + "resolved": "https://registry.npmjs.org/jake/-/jake-10.9.4.tgz", + "integrity": "sha512-wpHYzhxiVQL+IV05BLE2Xn34zW1S223hvjtqk0+gsPrwd/8JNLXJgZZM/iPFsYc1xyphF+6M6EvdE5E9MBGkDA==", + "license": "Apache-2.0", + "dependencies": { + "async": "^3.2.6", + "filelist": "^1.0.4", + "picocolors": "^1.1.1" + }, + "bin": { + "jake": "bin/cli.js" + }, + "engines": { + "node": ">=10" + } + }, "node_modules/jszip": { "version": "3.10.1", "resolved": "https://registry.npmjs.org/jszip/-/jszip-3.10.1.tgz", @@ -238,6 +313,18 @@ "events": "^3.2.0" } }, + "node_modules/minimatch": { + "version": "5.1.9", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-5.1.9.tgz", + "integrity": "sha512-7o1wEA2RyMP7Iu7GNba9vc0RWWGACJOCZBJX2GJWip0ikV+wcOsgVuY9uE8CPiyQhkGFSlhuSkZPavN7u1c2Fw==", + "license": "ISC", + "dependencies": { + "brace-expansion": "^2.0.1" + }, + "engines": { + "node": ">=10" + } + }, "node_modules/oidc-client-ts": { "version": "3.4.1", "resolved": "https://registry.npmjs.org/oidc-client-ts/-/oidc-client-ts-3.4.1.tgz", @@ -271,6 +358,12 @@ "integrity": "sha512-4hLB8Py4zZce5s4yd9XzopqwVv/yGNhV1Bl8NTmCq1763HeK2+EwVTv+leGeL13Dnh2wfbqowVPXCIO0z4taYw==", "license": "(MIT AND Zlib)" }, + "node_modules/picocolors": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.1.1.tgz", + "integrity": "sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA==", + "license": "ISC" + }, "node_modules/postgres": { "version": "3.3.4", "resolved": "https://registry.npmjs.org/postgres/-/postgres-3.3.4.tgz", @@ -383,11 +476,29 @@ "resolved": "https://registry.npmjs.org/another-json/-/another-json-0.2.0.tgz", "integrity": "sha512-/Ndrl68UQLhnCdsAzEXLMFuOR546o2qbYRqCglaNHbjXrwG1ayTcdwr3zkSGOGtGXDyR5X9nCFfnyG2AFJIsqg==" }, + "async": { + "version": "3.2.6", + "resolved": "https://registry.npmjs.org/async/-/async-3.2.6.tgz", + "integrity": "sha512-htCUDlxyyCLMgaM3xXg0C0LW2xqfuQ6p05pCEIsXuyQ+a1koYKTuBMzRNwmybfLgvJDMd0r1LTn4+E0Ti6C2AA==" + }, + "balanced-match": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", + "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==" + }, "base-x": { "version": "5.0.1", "resolved": "https://registry.npmjs.org/base-x/-/base-x-5.0.1.tgz", "integrity": "sha512-M7uio8Zt++eg3jPj+rHMfCC+IuygQHHCOU+IYsVtik6FWjuYpVt/+MRKcgsAMHh8mMFAwnB+Bs+mTrFiXjMzKg==" }, + "brace-expansion": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.1.0.tgz", + "integrity": "sha512-TN1kCZAgdgweJhWWpgKYrQaMNHcDULHkWwQIspdtjV4Y5aurRdZpjAqn6yX3FPqTA9ngHCc4hJxMAMgGfve85w==", + "requires": { + "balanced-match": "^1.0.0" + } + }, "bs58": { "version": "6.0.0", "resolved": "https://registry.npmjs.org/bs58/-/bs58-6.0.0.tgz", @@ -396,6 +507,14 @@ "base-x": "^5.0.0" } }, + "cloudflare-error-page": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/cloudflare-error-page/-/cloudflare-error-page-0.1.0.tgz", + "integrity": "sha512-Eogslg+b+hcGjzjdD/DeDD5/Yet0U6eck49FVrkrbTBy9rLMWPMpWd4otIG+vDSmqc9GVxpuBYV7PjNv3wAm4A==", + "requires": { + "ejs": "^3.1.10" + } + }, "content-type": { "version": "1.0.5", "resolved": "https://registry.npmjs.org/content-type/-/content-type-1.0.5.tgz", @@ -413,11 +532,27 @@ "flumm-fetch": "^1.0.1" } }, + "ejs": { + "version": "3.1.10", + "resolved": "https://registry.npmjs.org/ejs/-/ejs-3.1.10.tgz", + "integrity": "sha512-UeJmFfOrAQS8OJWPZ4qtgHyWExa088/MtK5UEyoJGFH67cDEXkZSviOiKRCZ4Xij0zxI3JECgYs3oKx+AizQBA==", + "requires": { + "jake": "^10.8.5" + } + }, "events": { "version": "3.3.0", "resolved": "https://registry.npmjs.org/events/-/events-3.3.0.tgz", "integrity": "sha512-mQw+2fkQbALzQ7V0MY0IqdnXNOeTtP4r0lN9z7AAawCXgqea7bDii20AYrIBrFd/Hx0M2Ocz6S111CaFkUcb0Q==" }, + "filelist": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/filelist/-/filelist-1.0.6.tgz", + "integrity": "sha512-5giy2PkLYY1cP39p17Ech+2xlpTRL9HLspOfEgm0L6CwBXBTgsK5ou0JtzYuepxkaQ/tvhCFIJ5uXo0OrM2DxA==", + "requires": { + "minimatch": "^5.0.1" + } + }, "flumm-fetch": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/flumm-fetch/-/flumm-fetch-1.0.1.tgz", @@ -448,6 +583,16 @@ "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", "integrity": "sha512-VLghIWNM6ELQzo7zwmcg0NmTVyWKYjvIeM83yjp0wRDTmUnrM678fQbcKBo6n2CJEF0szoG//ytg+TKla89ALQ==" }, + "jake": { + "version": "10.9.4", + "resolved": "https://registry.npmjs.org/jake/-/jake-10.9.4.tgz", + "integrity": "sha512-wpHYzhxiVQL+IV05BLE2Xn34zW1S223hvjtqk0+gsPrwd/8JNLXJgZZM/iPFsYc1xyphF+6M6EvdE5E9MBGkDA==", + "requires": { + "async": "^3.2.6", + "filelist": "^1.0.4", + "picocolors": "^1.1.1" + } + }, "jszip": { "version": "3.10.1", "resolved": "https://registry.npmjs.org/jszip/-/jszip-3.10.1.tgz", @@ -517,6 +662,14 @@ "events": "^3.2.0" } }, + "minimatch": { + "version": "5.1.9", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-5.1.9.tgz", + "integrity": "sha512-7o1wEA2RyMP7Iu7GNba9vc0RWWGACJOCZBJX2GJWip0ikV+wcOsgVuY9uE8CPiyQhkGFSlhuSkZPavN7u1c2Fw==", + "requires": { + "brace-expansion": "^2.0.1" + } + }, "oidc-client-ts": { "version": "3.4.1", "resolved": "https://registry.npmjs.org/oidc-client-ts/-/oidc-client-ts-3.4.1.tgz", @@ -538,6 +691,11 @@ "resolved": "https://registry.npmjs.org/pako/-/pako-1.0.11.tgz", "integrity": "sha512-4hLB8Py4zZce5s4yd9XzopqwVv/yGNhV1Bl8NTmCq1763HeK2+EwVTv+leGeL13Dnh2wfbqowVPXCIO0z4taYw==" }, + "picocolors": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.1.1.tgz", + "integrity": "sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA==" + }, "postgres": { "version": "3.3.4", "resolved": "https://registry.npmjs.org/postgres/-/postgres-3.3.4.tgz", diff --git a/package.json b/package.json index 47ee2c6..a3a5e61 100644 --- a/package.json +++ b/package.json @@ -22,12 +22,13 @@ "license": "MIT", "dependencies": { "@ruffle-rs/ruffle": "0.2.0-nightly.2026.4.21", + "cloudflare-error-page": "^0.1.0", "cuffeo": "git+https://git.lat/kibi/scuffeo.git", "flumm-fetch": "^1.0.1", "flummpress": "^2.0.5", + "jszip": "^3.10.1", "marked": "^18.0.2", "matrix-js-sdk": "^40.3.0-rc.0", - "postgres": "^3.3.4", - "jszip": "^3.10.1" + "postgres": "^3.3.4" } } diff --git a/src/inc/routes/register.mjs b/src/inc/routes/register.mjs index 03f6c67..ba72240 100644 --- a/src/inc/routes/register.mjs +++ b/src/inc/routes/register.mjs @@ -115,7 +115,7 @@ export default (router, tpl) => { from "user" where "login" = ${username.toLowerCase()} or "user" = ${username} - or ("email" is not null and "email" = ${email}) + ${email ? db`or ("email" is not null and "email" = ${email})` : db``} `; if (existing.length > 0) { diff --git a/src/index.mjs b/src/index.mjs index 08d6ffd..d4f3921 100644 --- a/src/index.mjs +++ b/src/index.mjs @@ -21,7 +21,52 @@ import { updateHallsCache, getHalls } from "./inc/halls_cache.mjs"; import { createI18n } from "./inc/i18n.mjs"; import security from "./inc/security.mjs"; -const nginx502 = ` +import { createRequire } from 'module'; +const _require = createRequire(import.meta.url); + +// ─── Private Society Gate ──────────────────────────────────────────────────── +// Powered by the cloudflare-error-page package. +// Each request gets a fresh page with a unique Ray ID + current UTC timestamp. +// +// Customise the visible text and status icons here: +const gateOptions = { + title: 'Bad Gateway', + error_code: '502', + what_happened: "There is an internal server error on Cloudflare's network.", + // what_can_i_do is injected dynamically below (Sign in button) + + error_source: 'host', + + browser_status: { + status: 'ok', + location: 'You', + name: 'Browser', + status_text: 'Working', + }, + cloudflare_status: { + status: 'ok', + location: 'Frankfurt', + name: 'Cloudflare', + status_text: 'Working', + }, + host_status: { + status: 'error', + location: 'Website', + name: 'Host', + status_text: 'Error', + }, + + more_information: { + hidden: false, + text: 'cloudflare.com', + link: '', + for: 'more information', + }, + perf_sec_by: { text: '', link: '' }, +}; + +// Fallback when the package isn't installed +const nginx502Fallback = `