Skip to content

Commit

Permalink
now custom domain for functions is set up and auth working! just need…
Browse files Browse the repository at this point in the history
… to get the CI/CD set up and the architecture diagram updated and firebase cleaned away
  • Loading branch information
adueck committed Nov 27, 2024
1 parent 3fb14eb commit 062f50b
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions functions/lambda/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,26 @@ import { getEnv } from "../lib/env-helper";
const app = new Hono();

app.get("/publish", async (c) => {
// check if caller is authorized as lingdocs admin
// might be nicer to abstract this into some middleware
const cookie = c.req.header("cookie");
if (!cookie) {
c.status(401);
return c.json({
ok: false,
error: "unauthorized",
});
}
const r = await fetch("https://account.lingdocs.com/api/user", {
headers: { Cookie: cookie },
});
const { ok, user } = await r.json();
if (ok !== true || typeof user !== "object" || !user.admin) {
return c.json({
ok: false,
error: "unauthorized",
});
}
const vars = getEnv(c);
const auth = new google.auth.GoogleAuth({
credentials: {
Expand Down

0 comments on commit 062f50b

Please sign in to comment.