aboutsummaryrefslogtreecommitdiff
path: root/web/pw-server/src
diff options
context:
space:
mode:
authorIlion Beyst <ilion.beyst@gmail.com>2022-03-24 20:43:27 +0100
committerIlion Beyst <ilion.beyst@gmail.com>2022-03-24 20:43:27 +0100
commit2479d1ec1a10410a72b2744f4067927112590f2a (patch)
tree335cd169781098909c6d9c5dcfed519b30de1b63 /web/pw-server/src
parent1692eeb592b9d7cef526d04ebf046c08390a3924 (diff)
downloadplanetwars.dev-2479d1ec1a10410a72b2744f4067927112590f2a.tar.xz
planetwars.dev-2479d1ec1a10410a72b2744f4067927112590f2a.zip
don't show save button when user is not logged in
Diffstat (limited to 'web/pw-server/src')
-rw-r--r--web/pw-server/src/lib/components/SubmitPane.svelte20
1 files changed, 14 insertions, 6 deletions
diff --git a/web/pw-server/src/lib/components/SubmitPane.svelte b/web/pw-server/src/lib/components/SubmitPane.svelte
index 497f3ce..919f578 100644
--- a/web/pw-server/src/lib/components/SubmitPane.svelte
+++ b/web/pw-server/src/lib/components/SubmitPane.svelte
@@ -1,5 +1,8 @@
<script lang="ts">
- import { createEventDispatcher, onMount } from "svelte";
+import { get_session_token } from "$lib/auth";
+
+ import { currentUser } from "$lib/stores/current_user";
+import { createEventDispatcher, onMount } from "svelte";
import Select from "svelte-select";
export let editSession;
@@ -54,6 +57,7 @@
method: "POST",
headers: {
"Content-Type": "application/json",
+ "Authorization": `Bearer ${get_session_token()}`,
},
body: JSON.stringify({
bot_name: botName,
@@ -94,12 +98,16 @@
</div>
<div class="save-form">
<h4>Save your bot</h4>
- <div>Add your bot to the opponents list</div>
- <input type="text" class="bot-name-input" placeholder="bot name" bind:value={botName} />
- {#if saveErrorText}
- <div class="error-text">{saveErrorText}</div>
+ {#if $currentUser}
+ <div>Add your bot to the opponents list</div>
+ <input type="text" class="bot-name-input" placeholder="bot name" bind:value={botName} />
+ {#if saveErrorText}
+ <div class="error-text">{saveErrorText}</div>
+ {/if}
+ <button class="submit-button save-button" on:click={saveBot}>Save</button>
+ {:else}
+ Sign in to add your bot to the opponents list.
{/if}
- <button class="submit-button save-button" on:click={saveBot}>Save</button>
</div>
</div>