Skip to content

Commit

Permalink
fix login
Browse files Browse the repository at this point in the history
  • Loading branch information
C4illin committed May 24, 2024
1 parent ac8f44b commit 8a32c2d
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/components/header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export const Header = ({ loggedIn }: { loggedIn?: boolean }) => {
<a href="/test">History</a>
</li>
<li>
<a href="/logout">Logout</a>
<a href="/logoff">Logout</a>
</li>
</ul>
);
Expand Down
2 changes: 0 additions & 2 deletions src/helpers/normalizeFiletype.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ export const normalizeOutputFiletype = (filetype: string): string => {
switch (lowercaseFiletype) {
case "jpeg":
return "jpg";
case "mpeg4":
return "mp4";
default:
return lowercaseFiletype;
}
Expand Down
19 changes: 12 additions & 7 deletions src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@ import {
getAllTargets,
getAllInputs,
} from "./converters/main";
import { normalizeFiletype } from "./helpers/normalizeFiletype";
import {
normalizeFiletype,
normalizeOutputFiletype,
} from "./helpers/normalizeFiletype";

const db = new Database("./data/mydb.sqlite", { create: true });
const uploadsDir = "./data/uploads/";
Expand Down Expand Up @@ -336,18 +339,18 @@ const app = new Elysia()
sameSite: "strict",
});

redirect("/");
return redirect("/");
},
{ body: t.Object({ email: t.String(), password: t.String() }) },
)
.get("/logout", ({ redirect, cookie: { auth } }) => {
.get("/logoff", ({ redirect, cookie: { auth } }) => {
if (auth?.value) {
auth.remove();
}

return redirect("/login");
})
.post("/logout", ({ redirect, cookie: { auth } }) => {
.post("/logoff", ({ redirect, cookie: { auth } }) => {
if (auth?.value) {
auth.remove();
}
Expand Down Expand Up @@ -415,15 +418,15 @@ const app = new Elysia()
</div>
<input type="file" name="file" multiple />
{/* <label for="convert_from">Convert from</label> */}
<select name="convert_from" aria-label="Convert from" required>
{/* <select name="convert_from" aria-label="Convert from" required>
<option selected disabled value="">
Convert from
</option>
{getPossibleInputs().map((input) => (
// biome-ignore lint/correctness/useJsxKeyInIterable: <explanation>
<option>{input}</option>
))}
</select>
</select> */}
</article>
<form method="post" action="/convert">
<input type="hidden" name="file_names" id="file_names" />
Expand Down Expand Up @@ -616,7 +619,7 @@ const app = new Elysia()
const fileTypeOrig = fileName.split(".").pop() as string;
const fileType = normalizeFiletype(fileTypeOrig);
const newFileExt = normalizeOutputFiletype(convertTo);
const newFileName = fileName.replace(fileTypeOrig, convertTo);
const newFileName = fileName.replace(fileTypeOrig, newFileExt);
const targetPath = `${userOutputDir}${newFileName}`;

await mainConverter(
Expand Down Expand Up @@ -863,6 +866,7 @@ const app = new Elysia()
Count: {inputs.length}
<ul>
{inputs.map((input) => (
// biome-ignore lint/correctness/useJsxKeyInIterable: <explanation>
<li>{input}</li>
))}
</ul>
Expand All @@ -871,6 +875,7 @@ const app = new Elysia()
Count: {targets.length}
<ul>
{targets.map((target) => (
// biome-ignore lint/correctness/useJsxKeyInIterable: <explanation>
<li>{target}</li>
))}
</ul>
Expand Down

0 comments on commit 8a32c2d

Please sign in to comment.