Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mask password #190

Merged
merged 12 commits into from
Jun 10, 2024
4 changes: 4 additions & 0 deletions frontend/src/_global.postcss
Original file line number Diff line number Diff line change
Expand Up @@ -137,3 +137,7 @@ button {
margin-inline-start: 40px;
}
}

::-ms-reveal {
display: none;
}
33 changes: 26 additions & 7 deletions frontend/src/lib/components/modals/ServerManager.svelte
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script lang="ts">
import { mdiAlert, mdiLoading, mdiServerNetwork, mdiTrashCan } from '@mdi/js';
import { mdiAlert, mdiEyeOffOutline, mdiEyeOutline, mdiLoading, mdiServerNetwork, mdiTrashCan } from '@mdi/js';
import { getTranslate } from '@tolgee/svelte';
import _ from 'lodash';

Expand Down Expand Up @@ -54,6 +54,7 @@
let advancedMode = false;

let addInProgress = false;
let maskPassword = true;

$: authString = encodeURIComponent(newServerUsername) + (newServerPassword ? ':' + encodeURIComponent(newServerPassword) : '');
$: actualPort = newRemoteType.type === 'remote' ? (newServerPort.length > 0 ? newServerPort : newRemoteType.defaultPort) : '';
Expand Down Expand Up @@ -161,6 +162,10 @@
},
placement: 'bottom',
} as PopupSettings]).reduce((acc, [k, v]) => ({ ...acc, [k as string]: v as PopupSettings }), {} as Record<string, PopupSettings>);

function redactRemoteURL(path: string) {
return path.replace(/(?<=.+:\/\/)(?:(.+?)(?::.*?)?)?(?=@)/, '$1:********');
}
</script>


Expand All @@ -175,7 +180,7 @@
{#each $remoteServers as remoteServer}
<tr>
<td class="break-all">{$installsMetadata[remoteServer].info?.launcher}</td>
<td class="break-all">{remoteServer}</td>
<td class="break-all">{redactRemoteURL(remoteServer)}</td>
<td>
{#if $installsMetadata[remoteServer]?.state === ficsitcli.InstallState.VALID}
{$installsMetadata[remoteServer].info?.type}
Expand Down Expand Up @@ -265,11 +270,25 @@
placeholder={$t('server-manager.username-placeholder', 'username')}
type="text"
bind:value={newServerUsername}/>
<input
class="input px-4 h-full"
placeholder={$t('server-manager.password-placeholder', 'password')}
type="text"
bind:value={newServerPassword}/>
<div class="input-group h-full grid-cols-[1fr_auto]">
<!-- This is a conditional because svelte doesn't allow dynamic type with bind:value -->
{#if maskPassword}
<input
class="px-4 h-full !outline-none"
placeholder={$t('server-manager.password-placeholder', 'password')}
type="password"
bind:value={newServerPassword}/>
{:else}
<input
class="px-4 h-full !outline-none"
placeholder={$t('server-manager.password-placeholder', 'password')}
type="text"
bind:value={newServerPassword}/>
{/if}
<button class="!outline-none" on:click={() => maskPassword = !maskPassword}>
<SvgIcon class="!w-4 !h-4" icon={maskPassword ? mdiEyeOutline : mdiEyeOffOutline} />
</button>
</div>
<input
class="input px-4 h-full sm:col-start-2"
placeholder={$t('server-manager.host-placeholder', 'host')}
Expand Down
Loading