Kaynağa Gözat

Ensure credentials

ghorsington 3 yıl önce
ebeveyn
işleme
e809158353

+ 1 - 1
web/src/routes/_layout.svelte

@@ -9,7 +9,7 @@
     { path }: PageData,
     session: AppSession
   ) {
-    const authResult = await this.fetch("/login/check");
+    const authResult = await this.fetch("/login/check", { credentials: "include" });
     const result = (await authResult.json()) as AuthInfo;
     if (path.startsWith("/login/")) {
       if (result.loggedIn) {

+ 1 - 0
web/src/routes/login/discord_auth.svelte

@@ -12,6 +12,7 @@
   onMount(async () => {
     const res = await fetch("/login/discord", {
       method: "post",
+      credentials: "include",
     });
     const result = (await res.json()) as Option<unknown, { error: string }>;
     if (!result.ok) {

+ 2 - 1
web/src/routes/rules/edit.svelte

@@ -5,7 +5,7 @@
     { path }: PageData,
     session: AppSession
   ) {
-    const result = await this.fetch("/rules/md");
+    const result = await this.fetch("/rules/md", { credentials: "include" });
     const md = (await result.json()) as Option<MDText, { error: string }>;
     if (md.ok) {
       return { rulesText: md.text };
@@ -38,6 +38,7 @@
 
   async function save() {
     const result = await fetch("/rules/md", {
+      credentials: "include",
       method: "post",
       headers: {
         Accept: "application/json",

+ 3 - 2
web/src/routes/rules/index.svelte

@@ -9,10 +9,10 @@
     { path }: PageData,
     session: AppSession
   ) {
-    const mdResult = await this.fetch("/rules/md");
+    const mdResult = await this.fetch("/rules/md", { credentials: "include" });
     const md = (await mdResult.json()) as Option<MDText, { error: string }>;
 
-    const verifyReusult = await this.fetch("/rules/verify");
+    const verifyReusult = await this.fetch("/rules/verify", { credentials: "include" });
     const verify = (await verifyReusult.json()) as VerifyInfo;
     return {
       rulesText: md.ok ? md.text : "",
@@ -49,6 +49,7 @@
   async function onVerified(e: { key: string }) {
     state = State.Verify;
     const result = await fetch("/rules/verify", {
+      credentials: "include",
       method: "post",
       headers: {
         Accept: "application/json",

+ 0 - 2
web/src/server.ts

@@ -39,10 +39,8 @@ const createSapperServer = async (): Promise<Express> => {
     app.use(
         session({
             secret: key,
-            secureProxy: !dev,
             name: "session",
             secure: !dev,
-            maxAge: 4400000,
         }),
         compression({ threshold: 0 }),
         sirv("static", { dev }),