Skip to content

Commit

Permalink
Locked new upload page, article creation page, and article edit page …
Browse files Browse the repository at this point in the history
…behind login
  • Loading branch information
ansengarvin committed Apr 26, 2024
1 parent 401a150 commit 955285d
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 0 deletions.
8 changes: 8 additions & 0 deletions frontend/src/routes/EditArticle.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import { navigate } from "svelte-routing";
import { Backend, setToken, type Article } from "../lib/backend";
import { onMount } from "svelte";
import { user } from "../lib/stores/user";
export let articleTitle: string;
let title: string = "";
Expand All @@ -13,6 +14,13 @@
let error = false;
let article: Article;
onMount(async () => {
if (!$user.loggedIn) {
alert(
"You are not logged in. You are being redirected to home. TODO: Make this better."
);
navigate("/");
}
try {
article = await Backend.getArticle(articleTitle);
} catch (e) {
Expand Down
11 changes: 11 additions & 0 deletions frontend/src/routes/Upload.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,17 @@
UploadSolid,
} from "flowbite-svelte-icons";
import { navigate } from "svelte-routing";
import { onMount } from "svelte";
import { user } from "../lib/stores/user";
onMount(async () => {
if (!$user.loggedIn) {
alert(
"You are not logged in. You are being redirected to home. TODO: Make this better."
);
navigate("/");
}
})
</script>

<section class="p-5">
Expand Down
10 changes: 10 additions & 0 deletions frontend/src/routes/UploadArticle.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,19 @@
import { Label, Input, Button, Helper } from "flowbite-svelte";
import { navigate } from "svelte-routing";
import { Backend, setToken } from "../lib/backend";
import { onMount } from "svelte";
import { user } from "../lib/stores/user";
let title: string = "";
let description: string = "";
let error = false;
onMount(async () => {
if (!$user.loggedIn) {
alert(
"You are not logged in. You are being redirected to home. TODO: Make this better."
);
navigate("/");
}
})
</script>

<section class="p-5">
Expand Down

0 comments on commit 955285d

Please sign in to comment.