Show Google sign-in even when site.json isn't deployed
/api/auth/providers read site.json to build Google's return address, and the deploy copies server/ into /srv/ngu-api without site.json, so it threw and the login page hid the button. Whether Google is on now depends only on the client id and secret; a missing return address is logged when a sign-in starts, naming GOOGLE_REDIRECT_URI and SITE_CONFIG. The docs say how the server is actually deployed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
d4b39251d9
commit
e932ee3007
4 changed files with 35 additions and 6 deletions
|
|
@ -136,6 +136,14 @@ auth.get("/providers", (c) =>
|
|||
auth.get("/google", (c) => {
|
||||
const config = googleConfig();
|
||||
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);
|
||||
setCookie(c, OAUTH_COOKIE, JSON.stringify({ state, verifier, next: safeNext(c.req.query("next")) }), {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue