Feature fixes: admin nav, hero event, schedule block, SEO, site settings, Google sign-in, QR tool #12

Merged
ngu-git-admin merged 14 commits from feature-fixes into main 2026-09-28 08:12:29 +01:00
4 changed files with 35 additions and 6 deletions
Showing only changes of commit e932ee3007 - Show all commits

View file

@ -53,8 +53,16 @@ and restart. Never commit the secret or paste it into the repo:
[Service] [Service]
Environment=GOOGLE_CLIENT_ID=<client id> Environment=GOOGLE_CLIENT_ID=<client id>
Environment=GOOGLE_CLIENT_SECRET=<client secret> Environment=GOOGLE_CLIENT_SECRET=<client secret>
Environment=GOOGLE_REDIRECT_URI=https://nextgenerationofunity.org/api/auth/google/callback
``` ```
`GOOGLE_REDIRECT_URI` must match the redirect URI in step 3 exactly.
Without it the API builds it from `site.json`'s `url`, which the API only
finds if `site.json` is deployed with it and `SITE_CONFIG` points at it
(the deploy copies `server/` into `/srv/ngu-api`, and `site.json` lives
at the repo root, so it isn't there by default). If neither is set,
sign-in fails and the log says so.
Optional: Optional:
| Variable | Default | | Variable | Default |

View file

@ -29,8 +29,11 @@ with it off it blocks everything.
## Production setup ## Production setup
1. The API needs to find two files. Both default to the repo layout 1. The API needs to find two files. Both default to the repo layout
(`site.json` at the root, the build in `dist/`); set them on the (`site.json` at the root, the build in `dist/`), which isn't how the
`ngu-api` unit if the deploy puts them elsewhere: server is deployed: the deploy copies `server/` into `/srv/ngu-api`,
so neither file is next to it. Copy `site.json` there with each
deploy (eg. rsync it to `/srv/ngu-api/site.json`) and set both on the
`ngu-api` unit:
```ini ```ini
[Service] [Service]

View file

@ -10,7 +10,9 @@
GOOGLE_CLIENT_ID from Google Cloud Console GOOGLE_CLIENT_ID from Google Cloud Console
GOOGLE_CLIENT_SECRET the same; never in the repo GOOGLE_CLIENT_SECRET the same; never in the repo
GOOGLE_REDIRECT_URI default <site.json url>/api/auth/google/callback GOOGLE_REDIRECT_URI default <site.json url>/api/auth/google/callback;
set it when the server is deployed
without site.json (SITE_CONFIG)
GOOGLE_ALLOWED_DOMAIN default nextgenerationofunity.org GOOGLE_ALLOWED_DOMAIN default nextgenerationofunity.org
With no client id or secret it's off: the login page doesn't With no client id or secret it's off: the login page doesn't
@ -45,10 +47,18 @@ export function googleConfig() {
const clientSecret = process.env.GOOGLE_CLIENT_SECRET; const clientSecret = process.env.GOOGLE_CLIENT_SECRET;
if (!clientId || !clientSecret) return null; if (!clientId || !clientSecret) return null;
let redirectUri = process.env.GOOGLE_REDIRECT_URI; // Whether Google is on depends only on the id and secret. The
// return address can come from site.json, which a deploy of the
// server alone may not have; that's reported where it's needed
// (the sign-in routes), rather than hiding the button.
let redirectUri = process.env.GOOGLE_REDIRECT_URI ?? null;
if (!redirectUri) { if (!redirectUri) {
const origin = (loadSite().url ?? "").replace(/\/$/, ""); try {
redirectUri = `${origin}/api/auth/google/callback`; const origin = (loadSite().url ?? "").replace(/\/$/, "");
if (origin) redirectUri = `${origin}/api/auth/google/callback`;
} catch {
redirectUri = null;
}
} }
return { return {

View file

@ -136,6 +136,14 @@ auth.get("/providers", (c) =>
auth.get("/google", (c) => { auth.get("/google", (c) => {
const config = googleConfig(); const config = googleConfig();
if (!config) return c.json({ error: "Google sign-in isn't set up." }, 404); if (!config) return c.json({ error: "Google sign-in isn't set up." }, 404);
if (!config.redirectUri) {
// Said in the log, where whoever runs the box will look; the
// person at the login page just learns it didn't work.
console.error(
"google login: no return address. Set GOOGLE_REDIRECT_URI, or SITE_CONFIG to a site.json with a url.",
);
return backToLogin(c, "google_failed");
}
const { url, state, verifier } = startLogin(config); const { url, state, verifier } = startLogin(config);
setCookie(c, OAUTH_COOKIE, JSON.stringify({ state, verifier, next: safeNext(c.req.query("next")) }), { setCookie(c, OAUTH_COOKIE, JSON.stringify({ state, verifier, next: safeNext(c.req.query("next")) }), {