From e37c73e33a4aaf7fb8d25b5af03627f20bcda19f Mon Sep 17 00:00:00 2001
From: Doog <157747121+doogongithub@users.noreply.github.com>
Date: Sat, 24 Feb 2024 20:08:35 -0500
Subject: add gitignore

---
 fe/src/lib/LoginForm.svelte | 64 +++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 64 insertions(+)
 create mode 100644 fe/src/lib/LoginForm.svelte

(limited to 'fe/src/lib/LoginForm.svelte')

diff --git a/fe/src/lib/LoginForm.svelte b/fe/src/lib/LoginForm.svelte
new file mode 100644
index 0000000..22c0faf
--- /dev/null
+++ b/fe/src/lib/LoginForm.svelte
@@ -0,0 +1,64 @@
+<script lang='ts'>
+import { token } from '../stores/auth';
+import Card from './Card.svelte';
+
+let user = {
+    username: '',
+    password: ''
+}
+
+let error;
+
+interface CredentialObject {
+    username: string;
+    password: string;
+}
+
+function prepareCredentials ({ username, password }: CredentialObject): string {
+    return btoa(`${username}:${password}`);
+}
+
+async function onSubmit (e) {
+    if (!user.username || !user.password) {
+        error = 'please enter your username and password';
+        return;
+    }
+   const auth = prepareCredentials(user);
+
+   const response = await fetch('http://localhost:8080/api/v1/auth', {
+        method: 'POST',
+        headers: {
+            'Authorization': `Basic ${auth}`,
+        },
+   });
+
+    if (response.status === 401) {
+        error = "Your username or password is wrong";
+        return;
+    }
+
+    if (response.ok) {
+        const { token: apiToken } = await response.json();
+        token.authenticate(apiToken);
+    }
+
+    error = null;
+}
+</script>
+
+<Card>
+    <form class="form" on:submit|preventDefault={onSubmit}>
+        <div class='form input group'>
+            <label for="username">Username</label>
+            <input bind:value={user.username} id="username" name='username' type="text" autocomplete="username" />
+        </div>
+        <div class='form input group'>
+            <label for="password">Password</label>
+            <input bind:value={user.password} id="password" name='password' type="password" autocomplete="current-password"/>
+        </div>
+        {#if error}
+            <p class="error">{error}</p>
+        {/if}
+        <button type="submit">Log in</button>
+    </form>
+</Card>
-- 
cgit v1.1


From 9f9a33cbf55d38987a66b709284d2bb4ffea0fe9 Mon Sep 17 00:00:00 2001
From: Doog <157747121+doogongithub@users.noreply.github.com>
Date: Thu, 29 Feb 2024 20:13:48 -0500
Subject: modify api, build additional FE components, add types

---
 fe/src/lib/LoginForm.svelte | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)

(limited to 'fe/src/lib/LoginForm.svelte')

diff --git a/fe/src/lib/LoginForm.svelte b/fe/src/lib/LoginForm.svelte
index 22c0faf..499a457 100644
--- a/fe/src/lib/LoginForm.svelte
+++ b/fe/src/lib/LoginForm.svelte
@@ -1,8 +1,8 @@
 <script lang='ts'>
-import { token } from '../stores/auth';
+import { token, user, preferences } from '../stores/auth';
 import Card from './Card.svelte';
 
-let user = {
+let credentials: CredentialObject = {
     username: '',
     password: ''
 }
@@ -19,11 +19,11 @@ function prepareCredentials ({ username, password }: CredentialObject): string {
 }
 
 async function onSubmit (e) {
-    if (!user.username || !user.password) {
+    if (!credentials.username || !credentials.password) {
         error = 'please enter your username and password';
         return;
     }
-   const auth = prepareCredentials(user);
+   const auth = prepareCredentials(credentials);
 
    const response = await fetch('http://localhost:8080/api/v1/auth', {
         method: 'POST',
@@ -38,7 +38,9 @@ async function onSubmit (e) {
     }
 
     if (response.ok) {
-        const { token: apiToken } = await response.json();
+        const { token: apiToken, user: userData, preferences: userPreferences } = await response.json();
+        user.setUser(userData);
+        preferences.set(userPreferences);
         token.authenticate(apiToken);
     }
 
@@ -50,11 +52,11 @@ async function onSubmit (e) {
     <form class="form" on:submit|preventDefault={onSubmit}>
         <div class='form input group'>
             <label for="username">Username</label>
-            <input bind:value={user.username} id="username" name='username' type="text" autocomplete="username" />
+            <input bind:value={credentials.username} id="username" name='username' type="text" autocomplete="username" />
         </div>
         <div class='form input group'>
             <label for="password">Password</label>
-            <input bind:value={user.password} id="password" name='password' type="password" autocomplete="current-password"/>
+            <input bind:value={credentials.password} id="password" name='password' type="password" autocomplete="current-password"/>
         </div>
         {#if error}
             <p class="error">{error}</p>
-- 
cgit v1.1


From afeffe31bd7d0f8333627a972e1d32e64a325b5b Mon Sep 17 00:00:00 2001
From: Zach Berwaldt <zberwaldt@tutamail.com>
Date: Fri, 1 Mar 2024 18:17:42 -0500
Subject: reformat fe

---
 fe/src/lib/LoginForm.svelte | 105 ++++++++++++++++++++++++++------------------
 1 file changed, 62 insertions(+), 43 deletions(-)

(limited to 'fe/src/lib/LoginForm.svelte')

diff --git a/fe/src/lib/LoginForm.svelte b/fe/src/lib/LoginForm.svelte
index 499a457..bf6d9ad 100644
--- a/fe/src/lib/LoginForm.svelte
+++ b/fe/src/lib/LoginForm.svelte
@@ -1,66 +1,85 @@
-<script lang='ts'>
-import { token, user, preferences } from '../stores/auth';
-import Card from './Card.svelte';
+<script lang="ts">
+  import { token, user, preferences } from "../stores/auth";
+  import Card from "./Card.svelte";
 
-let credentials: CredentialObject = {
-    username: '',
-    password: ''
-}
+  let credentials: CredentialObject = {
+    username: "",
+    password: "",
+  };
 
-let error;
+  let error: string | null = null;
 
-interface CredentialObject {
+  interface CredentialObject {
     username: string;
     password: string;
-}
+  }
 
-function prepareCredentials ({ username, password }: CredentialObject): string {
+  function prepareCredentials({
+    username,
+    password,
+  }: CredentialObject): string {
     return btoa(`${username}:${password}`);
-}
+  }
 
-async function onSubmit (e) {
+  async function onSubmit(e: Event) {
     if (!credentials.username || !credentials.password) {
-        error = 'please enter your username and password';
-        return;
+      error = "please enter your username and password";
+      return;
     }
-   const auth = prepareCredentials(credentials);
+    const auth = prepareCredentials(credentials);
 
-   const response = await fetch('http://localhost:8080/api/v1/auth', {
-        method: 'POST',
-        headers: {
-            'Authorization': `Basic ${auth}`,
-        },
-   });
+    const response = await fetch("http://localhost:8080/api/v1/auth", {
+      method: "POST",
+      headers: {
+        Authorization: `Basic ${auth}`,
+      },
+    });
 
     if (response.status === 401) {
-        error = "Your username or password is wrong";
-        return;
+      error = "Your username or password is wrong";
+      return;
     }
 
     if (response.ok) {
-        const { token: apiToken, user: userData, preferences: userPreferences } = await response.json();
-        user.setUser(userData);
-        preferences.set(userPreferences);
-        token.authenticate(apiToken);
+      const {
+        token: apiToken,
+        user: userData,
+        preferences: userPreferences,
+      } = await response.json();
+      user.setUser(userData);
+      preferences.set(userPreferences);
+      token.authenticate(apiToken);
     }
 
     error = null;
-}
+  }
 </script>
 
 <Card>
-    <form class="form" on:submit|preventDefault={onSubmit}>
-        <div class='form input group'>
-            <label for="username">Username</label>
-            <input bind:value={credentials.username} id="username" name='username' type="text" autocomplete="username" />
-        </div>
-        <div class='form input group'>
-            <label for="password">Password</label>
-            <input bind:value={credentials.password} id="password" name='password' type="password" autocomplete="current-password"/>
-        </div>
-        {#if error}
-            <p class="error">{error}</p>
-        {/if}
-        <button type="submit">Log in</button>
-    </form>
+  <form class="form" on:submit|preventDefault={onSubmit}>
+    <div class="form input group">
+      <label for="username">Username</label>
+      <input
+        bind:value={credentials.username}
+        id="username"
+        name="username"
+        type="text"
+        autocomplete="username"
+      />
+    </div>
+    <div class="form input group">
+      <label for="password">Password</label>
+      <input
+        bind:value={credentials.password}
+        id="password"
+        name="password"
+        type="password"
+        autocomplete="current-password"
+      />
+    </div>
+    {#if error}
+      <p class="error">{error}</p>
+    {/if}
+    <button type="submit">Log in</button>
+  </form>
 </Card>
-- 
cgit v1.1


From 9cae9c1d2a0b4f7fa72f3075541b9ffafe1a7275 Mon Sep 17 00:00:00 2001
From: Zach Berwaldt <zberwaldt@tutamail.com>
Date: Fri, 15 Mar 2024 18:49:43 -0400
Subject: Add routes for preference, clean up and add types

---
 fe/src/lib/LoginForm.svelte | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

(limited to 'fe/src/lib/LoginForm.svelte')

diff --git a/fe/src/lib/LoginForm.svelte b/fe/src/lib/LoginForm.svelte
index bf6d9ad..8c3c288 100644
--- a/fe/src/lib/LoginForm.svelte
+++ b/fe/src/lib/LoginForm.svelte
@@ -47,7 +47,7 @@
         preferences: userPreferences,
       } = await response.json();
       user.setUser(userData);
-      preferences.set(userPreferences);
+      preferences.setPreference(userPreferences);
       token.authenticate(apiToken);
     }
 
-- 
cgit v1.1


From fd1332a3df191577e91c6d846a8b5db1747099fd Mon Sep 17 00:00:00 2001
From: Zach Berwaldt <zberwaldt@tutamail.com>
Date: Fri, 15 Mar 2024 22:00:10 -0400
Subject: cleanup

---
 fe/src/lib/LoginForm.svelte | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

(limited to 'fe/src/lib/LoginForm.svelte')

diff --git a/fe/src/lib/LoginForm.svelte b/fe/src/lib/LoginForm.svelte
index 8c3c288..cf5febf 100644
--- a/fe/src/lib/LoginForm.svelte
+++ b/fe/src/lib/LoginForm.svelte
@@ -1,6 +1,7 @@
 <script lang="ts">
   import { token, user, preferences } from "../stores/auth";
   import Card from "./Card.svelte";
+  import { apiURL } from "../utils";
 
   let credentials: CredentialObject = {
     username: "",
@@ -28,7 +29,7 @@
     }
     const auth = prepareCredentials(credentials);
 
-    const response = await fetch("http://localhost:8080/api/v1/auth", {
+    const response = await fetch(apiURL("auth"), {
       method: "POST",
       headers: {
         Authorization: `Basic ${auth}`,
-- 
cgit v1.1

