nsarrazin HF staff commited on
Commit
545f27c
1 Parent(s): d779ad0

Login button sends you directly to login page (#501)

Browse files

* Login button sends you directly to login page.

* use _parent for target

src/lib/components/LoginModal.svelte CHANGED
@@ -1,5 +1,4 @@
1
  <script lang="ts">
2
- import { browser } from "$app/environment";
3
  import { base } from "$app/paths";
4
  import { page } from "$app/stores";
5
  import { PUBLIC_APP_DATA_SHARING, PUBLIC_APP_NAME, PUBLIC_VERSION } from "$env/static/public";
@@ -8,8 +7,6 @@
8
  import type { LayoutData } from "../../routes/$types";
9
  import Logo from "./icons/Logo.svelte";
10
  export let settings: LayoutData["settings"];
11
-
12
- const isIframe = browser && window.self !== window.parent;
13
  </script>
14
 
15
  <Modal>
@@ -45,7 +42,7 @@
45
  {/if}
46
  <form
47
  action="{base}/{$page.data.requiresLogin ? 'login' : 'settings'}"
48
- target={isIframe ? "_blank" : ""}
49
  method="POST"
50
  class="flex w-full flex-col items-center gap-2"
51
  >
 
1
  <script lang="ts">
 
2
  import { base } from "$app/paths";
3
  import { page } from "$app/stores";
4
  import { PUBLIC_APP_DATA_SHARING, PUBLIC_APP_NAME, PUBLIC_VERSION } from "$env/static/public";
 
7
  import type { LayoutData } from "../../routes/$types";
8
  import Logo from "./icons/Logo.svelte";
9
  export let settings: LayoutData["settings"];
 
 
10
  </script>
11
 
12
  <Modal>
 
42
  {/if}
43
  <form
44
  action="{base}/{$page.data.requiresLogin ? 'login' : 'settings'}"
45
+ target="_parent"
46
  method="POST"
47
  class="flex w-full flex-col items-center gap-2"
48
  >
src/lib/components/NavMenu.svelte CHANGED
@@ -21,8 +21,6 @@
21
 
22
  export let canLogin: boolean;
23
  export let user: LayoutData["user"];
24
-
25
- export let loginModalVisible;
26
  </script>
27
 
28
  <div class="sticky top-0 flex flex-none items-center justify-between px-3 py-3.5 max-sm:pt-0">
@@ -66,13 +64,14 @@
66
  </form>
67
  {/if}
68
  {#if canLogin}
69
- <button
70
- on:click={() => (loginModalVisible = true)}
71
- type="button"
72
- class="flex h-9 flex-none items-center gap-1.5 rounded-lg pl-3 pr-2 text-gray-500 hover:bg-gray-100 dark:text-gray-400 dark:hover:bg-gray-700"
73
- >
74
- Login
75
- </button>
 
76
  {/if}
77
  <button
78
  on:click={switchTheme}
 
21
 
22
  export let canLogin: boolean;
23
  export let user: LayoutData["user"];
 
 
24
  </script>
25
 
26
  <div class="sticky top-0 flex flex-none items-center justify-between px-3 py-3.5 max-sm:pt-0">
 
64
  </form>
65
  {/if}
66
  {#if canLogin}
67
+ <form action="{base}/login" method="POST" target="_parent">
68
+ <button
69
+ type="submit"
70
+ class="flex h-9 flex-none items-center gap-1.5 rounded-lg pl-3 pr-2 text-gray-500 hover:bg-gray-100 dark:text-gray-400 dark:hover:bg-gray-700"
71
+ >
72
+ Login
73
+ </button>
74
+ </form>
75
  {/if}
76
  <button
77
  on:click={switchTheme}
src/routes/+layout.svelte CHANGED
@@ -99,8 +99,6 @@
99
  (data.requiresLogin
100
  ? !data.user
101
  : !data.settings.ethicsModalAcceptedAt && !!PUBLIC_APP_DISCLAIMER);
102
-
103
- let loginModalVisible = false;
104
  </script>
105
 
106
  <svelte:head>
@@ -163,7 +161,6 @@
163
  conversations={data.conversations}
164
  user={data.user}
165
  canLogin={data.user === undefined && data.requiresLogin}
166
- bind:loginModalVisible
167
  on:shareConversation={(ev) => shareConversation(ev.detail.id, ev.detail.title)}
168
  on:deleteConversation={(ev) => deleteConversation(ev.detail)}
169
  on:clickSettings={() => (isSettingsOpen = true)}
@@ -175,7 +172,6 @@
175
  conversations={data.conversations}
176
  user={data.user}
177
  canLogin={data.user === undefined && data.requiresLogin}
178
- bind:loginModalVisible
179
  on:shareConversation={(ev) => shareConversation(ev.detail.id, ev.detail.title)}
180
  on:deleteConversation={(ev) => deleteConversation(ev.detail)}
181
  on:clickSettings={() => (isSettingsOpen = true)}
@@ -192,7 +188,7 @@
192
  models={data.models}
193
  />
194
  {/if}
195
- {#if (requiresLogin && data.messagesBeforeLogin === 0) || loginModalVisible}
196
  <LoginModal settings={data.settings} />
197
  {/if}
198
  <slot />
 
99
  (data.requiresLogin
100
  ? !data.user
101
  : !data.settings.ethicsModalAcceptedAt && !!PUBLIC_APP_DISCLAIMER);
 
 
102
  </script>
103
 
104
  <svelte:head>
 
161
  conversations={data.conversations}
162
  user={data.user}
163
  canLogin={data.user === undefined && data.requiresLogin}
 
164
  on:shareConversation={(ev) => shareConversation(ev.detail.id, ev.detail.title)}
165
  on:deleteConversation={(ev) => deleteConversation(ev.detail)}
166
  on:clickSettings={() => (isSettingsOpen = true)}
 
172
  conversations={data.conversations}
173
  user={data.user}
174
  canLogin={data.user === undefined && data.requiresLogin}
 
175
  on:shareConversation={(ev) => shareConversation(ev.detail.id, ev.detail.title)}
176
  on:deleteConversation={(ev) => deleteConversation(ev.detail)}
177
  on:clickSettings={() => (isSettingsOpen = true)}
 
188
  models={data.models}
189
  />
190
  {/if}
191
+ {#if requiresLogin && data.messagesBeforeLogin === 0}
192
  <LoginModal settings={data.settings} />
193
  {/if}
194
  <slot />