Loggest thine Stuff
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

53 lines
1.5 KiB

  1. <script lang="ts" context="module">
  2. import type { Load } from "@sveltejs/kit/types/internal";
  3. import { Auth, Amplify } from "aws-amplify";
  4. import backgroundImage from "$lib/assets/background.jpg";
  5. Amplify.configure({
  6. Auth: {
  7. region: import.meta.env.VITE_STUFFLOG3_AWS_POOL_REGION,
  8. userPoolId: import.meta.env.VITE_STUFFLOG3_AWS_POOL_ID,
  9. userPoolWebClientId: import.meta.env.VITE_STUFFLOG3_AWS_POOL_PUBLIC_CLIENT_ID,
  10. },
  11. ssr: false,
  12. });
  13. export const load: Load = async({ url }) => {
  14. let idToken: string | null = null;
  15. try {
  16. const sess = await Auth.currentSession();
  17. idToken = sess?.getIdToken()?.getJwtToken();
  18. } catch(err) {
  19. console.warn(err);
  20. }
  21. if (idToken == null && !url.pathname.startsWith("/login")) {
  22. return { status: 302, redirect: "/login" };
  23. }
  24. return { props: {}, stuff: { idToken } };
  25. }
  26. export const ssr = false;
  27. </script>
  28. <script lang="ts">
  29. import { page } from "$app/stores";
  30. import Background from "$lib/components/layout/Background.svelte"
  31. import TimeContext from "$lib/components/contexts/TimeContext.svelte";
  32. import ModalContext from "$lib/components/contexts/ModalContext.svelte";
  33. let opacity = 0.175;
  34. $: opacity = $page.url.pathname === "/" ? 0.3 : 0.2;
  35. export const ssr = false;
  36. </script>
  37. <ModalContext>
  38. <TimeContext>
  39. <Background src={backgroundImage} initialOrientation="landscape" opacity={opacity} />
  40. <slot></slot>
  41. </TimeContext>
  42. </ModalContext>