display client info and unlock errors to user

This commit is contained in:
Joseph Montanaro
2022-12-21 13:42:12 -08:00
parent 69475604c0
commit 50f0985f4f
8 changed files with 95 additions and 27 deletions

View File

@ -34,14 +34,23 @@
<h2 class="text-3xl text-gray-200">An application would like to access your AWS credentials.</h2>
<button on:click={approve}>
<svg class="w-32 stroke-green-500" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="1">
<path stroke-linecap="round" stroke-linejoin="round" d="M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z" />
</svg>
</button>
<div class="text-center">
<ul class="text-gray-200">
{#each appState.currentRequest.clients as client}
<li>PID: {client.pid}</li>
<li>Path: {client.exe}</li>
{/each}
</ul>
<button on:click={deny}>
<svg class="w-32 stroke-red-600" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="1">
<path stroke-linecap="round" stroke-linejoin="round" d="M10 14l2-2m0 0l2-2m-2 2l-2-2m2 2l2 2m7-2a9 9 0 11-18 0 9 9 0 0118 0z" />
</svg>
</button>
<button on:click={approve}>
<svg class="w-32 stroke-green-500" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="1">
<path stroke-linecap="round" stroke-linejoin="round" d="M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z" />
</svg>
</button>
<button on:click={deny}>
<svg class="w-32 stroke-red-600" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="1">
<path stroke-linecap="round" stroke-linejoin="round" d="M10 14l2-2m0 0l2-2m-2 2l-2-2m2 2l2 2m7-2a9 9 0 11-18 0 9 9 0 0118 0z" />
</svg>
</button>
</div>

View File

@ -4,18 +4,31 @@
import { invoke } from '@tauri-apps/api/tauri';
export let appState;
onMount(async () => {
let error = null;
const dispatch = createEventDispatcher();
async function respond() {
let response = {
id: appState.currentRequest.id,
approval: 'Approved',
}
await invoke('respond', {response});
appState.currentRequest = null;
});
};
const dispatch = createEventDispatcher();
window.setTimeout(() => dispatch('navigate', {target: 'Home'}), 3000);
try {
await invoke('respond', {response});
appState.currentRequest = null;
}
catch (e) {
error = e;
}
window.setTimeout(() => dispatch('navigate', {target: 'Home'}), 3000);
}
onMount(respond);
</script>
<h1 class="text-4xl text-gray-300">Approved!</h1>
{#if error}
<div class="text-red-400">Error attempting to send approval: {error}</div>
{:else}
<h1 class="text-4xl text-gray-300">Approved!</h1>
{/if}

View File

@ -6,6 +6,7 @@
const dispatch = createEventDispatcher();
let error = null;
let passphrase = '';
async function unlock() {
console.log('invoking unlock command.')
@ -21,11 +22,14 @@
}
}
catch (e) {
console.log('Unlock error:', e);
error = e;
}
}
</script>
{#if error}
<div class="text-red-400">{error}</div>
{/if}
<form action="#" on:submit|preventDefault="{unlock}">
<div class="text-gray-200">Enter your passphrase:</div>
<input autofocus class="text-gray-200 bg-zinc-800" type="password" placeholder="correct horse battery staple" bind:value="{passphrase}" />