-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* use server login when SystemWebView is not enabled, also fix server-based login to support more then one request and cancel requests that hang for 5 minutes * removed --emptyOutDir from `build-app` otherwise the FwLiteWeb server fails to start when both the build and server are started at once due to the missing js files
- Loading branch information
Showing
7 changed files
with
122 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
<script context="module" lang="ts"> | ||
import type {IAuthService} from '$lib/dotnet-types'; | ||
import {type Readable, writable, type Writable} from 'svelte/store'; | ||
let shouldUseSystemWebViewStore: Writable<boolean> | undefined = undefined; | ||
function useSystemWebView(authService: IAuthService): Readable<boolean> { | ||
if (shouldUseSystemWebViewStore) return shouldUseSystemWebViewStore; | ||
shouldUseSystemWebViewStore = writable(true); | ||
void authService.useSystemWebView().then(r => shouldUseSystemWebViewStore!.set(r)); | ||
return shouldUseSystemWebViewStore; | ||
} | ||
</script> | ||
|
||
<script lang="ts"> | ||
import {mdiLogin, mdiLogout} from '@mdi/js'; | ||
import {Button} from 'svelte-ux'; | ||
import type {ILexboxServer} from '$lib/dotnet-types'; | ||
import {useAuthService} from '$lib/services/service-provider'; | ||
import {createEventDispatcher} from 'svelte'; | ||
const authService = useAuthService(); | ||
const shouldUseSystemWebView = useSystemWebView(authService); | ||
const dispatch = createEventDispatcher<{ | ||
status: 'logged-in' | 'logged-out' | ||
}>(); | ||
export let isLoggedIn: boolean; | ||
export let server: ILexboxServer; | ||
let loading = false; | ||
async function login(server: ILexboxServer) { | ||
loading = true; | ||
try { | ||
await authService.signInWebView(server); | ||
dispatch('status', 'logged-in'); | ||
} finally { | ||
loading = false; | ||
} | ||
} | ||
async function logout(server: ILexboxServer) { | ||
loading = true; | ||
try { | ||
await authService.logout(server); | ||
dispatch('status', 'logged-out'); | ||
} finally { | ||
loading = false; | ||
} | ||
} | ||
</script> | ||
|
||
{#if isLoggedIn} | ||
<Button {loading} | ||
variant="fill" | ||
color="primary" | ||
on:click={() => logout(server)} | ||
icon={mdiLogout}> | ||
Logout | ||
</Button> | ||
{:else} | ||
{#if $shouldUseSystemWebView} | ||
<Button {loading} | ||
variant="fill-light" | ||
color="primary" | ||
on:click={() => login(server)} | ||
icon={mdiLogin}> | ||
Login | ||
</Button> | ||
{:else} | ||
<Button {loading} | ||
variant="fill-light" | ||
color="primary" | ||
href="/api/auth/login/{server.id}" | ||
icon={mdiLogin}> | ||
Login | ||
</Button> | ||
{/if} | ||
{/if} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters