~kyoheiu/frssco

9db4c9d2d3f967803311bbc87c1c931d31e54ea5 — Kyohei Uto 9 months ago 064ba24
Use cokkie auth only if .env is set
1 files changed, 7 insertions(+), 3 deletions(-)

M routes/index.tsx
M routes/index.tsx => routes/index.tsx +7 -3
@@ 7,6 7,7 @@ import { Database } from "https://deno.land/x/sqlite3@0.9.1/mod.ts";
import Menu from "../islands/Menu.tsx";
import { getCookies } from "std/http/cookie.ts";
import IconLogin from "https://deno.land/x/tabler_icons_tsx@0.0.3/tsx/login.tsx";
import "std/dotenv/load.ts";

const compareUpdated = (a: Entry, b: Entry): number => {
  if (b.date > a.date) {


@@ 37,9 38,12 @@ const Login = () => {

export const handler: Handlers<FeedsState> = {
  async GET(req, ctx) {
    const cookies = getCookies(req.headers);
    if (cookies.auth !== "frssco_logged_in") {
      return ctx.render!({ feeds: [], loggedIn: false });
    // If .env is not set, the login process is skipped
    if (Deno.env.get("USERNAME")) {
      const cookies = getCookies(req.headers);
      if (cookies.auth !== "frssco_logged_in") {
        return ctx.render!({ feeds: [], loggedIn: false });
      }
    }
    const url = new URL(req.url);
    const q = url.searchParams.get("url");