now custom domain for functions is set up and auth working! just need to get the CI/CD set up and the architecture diagram updated and firebase cleaned away
This commit is contained in:
parent
3fb14ebe4e
commit
062f50b3a2
|
@ -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: {
|
||||
|
|
Loading…
Reference in New Issue