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
42 changes: 40 additions & 2 deletions frontend/src/lib/components/modals/ServerManager.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,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 All @@ -62,6 +63,19 @@
return newRemoteType.protocol + authString + '@' + newServerHost + ':' + actualPort + '/' + trimmedPath;
})();

$: displayPath = (() => {
if (newRemoteType.type === 'local') {
return newServerPath;
}
if (advancedMode) {
return newRemoteType.protocol + newServerPath;
}
if (maskPassword) {
return newRemoteType.protocol + encodeURIComponent(newServerUsername) + ':*****@' + newServerHost + ':' + actualPort + '/' + trimmedPath;
}
return newRemoteType.protocol + authString + '@' + newServerHost + ':' + actualPort + '/' + trimmedPath;
})();

$: isValid = (() => {
if (newRemoteType.type === 'local') {
return newServerPath.length > 0;
Expand Down Expand Up @@ -124,6 +138,10 @@
},
placement: 'bottom',
} as PopupSettings]).reduce((acc, [k, v]) => ({ ...acc, [k as string]: v as PopupSettings }), {} as Record<string, PopupSettings>);

function toggleMaskPassword() {
maskPassword = !maskPassword;
}
</script>


Expand Down Expand Up @@ -227,11 +245,19 @@
placeholder="user"
type="text"
bind:value={newServerUsername}/>
<input
{#if maskPassword}
<input
class="input px-4 h-full"
placeholder="pass"
type="password"
mircearoata marked this conversation as resolved.
Show resolved Hide resolved
bind:value={newServerPassword}/>
{:else}
<input
class="input px-4 h-full"
placeholder="pass"
type="text"
bind:value={newServerPassword}/>
{/if}
elightcap marked this conversation as resolved.
Show resolved Hide resolved
<input
class="input px-4 h-full sm:col-start-2"
placeholder="host"
Expand All @@ -248,7 +274,7 @@
type="text"
bind:value={newServerPath}/>
<p class="sm:col-start-2 col-span-2">
Complete path: {fullInstallPath}
Complete path: {displayPath}
</p>
{/if}
<button class="btn sm:col-start-2 col-span-2 text-sm whitespace-break-spaces bg-surface-200-700-token" on:click={() => advancedMode = !advancedMode}>
Expand Down Expand Up @@ -281,6 +307,18 @@
class="h-5 w-5"
icon={mdiServerNetwork} />
</button>
<button
class="btn h-full text-sm bg-primary-600 text-secondary-900 col-start-2 sm:col-start-4 row-start-2"
disabled={addInProgress}
elightcap marked this conversation as resolved.
Show resolved Hide resolved
on:click={() => toggleMaskPassword()}>
<span>
{#if maskPassword}
Show Password
{:else}
Hide Password
{/if}
</span>
</button>
</div>
<p>{err}</p>
</section>
Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ require (
github.com/satisfactorymodding/ficsit-resolver v0.0.2
github.com/spf13/viper v1.18.1
github.com/tawesoft/golib/v2 v2.10.0
github.com/wailsapp/wails/v2 v2.7.1
github.com/wailsapp/wails/v2 v2.8.0
github.com/zishang520/engine.io v1.5.12
github.com/zishang520/socket.io v1.3.2
golang.org/x/sys v0.16.0
Expand Down Expand Up @@ -88,7 +88,7 @@ require (
go.uber.org/multierr v1.11.0 // indirect
golang.org/x/crypto v0.18.0 // indirect
golang.org/x/exp v0.0.0-20231214170342-aacd6d4b4611 // indirect
golang.org/x/net v0.19.0 // indirect
golang.org/x/net v0.20.0 // indirect
golang.org/x/sync v0.5.0 // indirect
golang.org/x/text v0.14.0 // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
Expand Down
8 changes: 4 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -189,8 +189,8 @@ github.com/wailsapp/go-webview2 v1.0.10 h1:PP5Hug6pnQEAhfRzLCoOh2jJaPdrqeRgJKZhy
github.com/wailsapp/go-webview2 v1.0.10/go.mod h1:Uk2BePfCRzttBBjFrBmqKGJd41P6QIHeV9kTgIeOZNo=
github.com/wailsapp/mimetype v1.4.1 h1:pQN9ycO7uo4vsUUuPeHEYoUkLVkaRntMnHJxVwYhwHs=
github.com/wailsapp/mimetype v1.4.1/go.mod h1:9aV5k31bBOv5z6u+QP8TltzvNGJPmNJD4XlAL3U+j3o=
github.com/wailsapp/wails/v2 v2.7.1 h1:HAzp2c5ODOzsLC6ZMDVtNOB72ozM7/SJecJPB2Ur+UU=
github.com/wailsapp/wails/v2 v2.7.1/go.mod h1:oIJVwwso5fdOgprBYWXBBqtx6PaSvxg8/KTQHNGkadc=
github.com/wailsapp/wails/v2 v2.8.0 h1:b2NNn99uGPiN6P5bDsnPwOJZWtAOUhNLv7Vl+YxMTr4=
github.com/wailsapp/wails/v2 v2.8.0/go.mod h1:EFUGWkUX3KofO4fmKR/GmsLy3HhPH7NbyOEaMt8lBF0=
github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e h1:JVG44RsyaB9T2KIHavMF/ppJZNG9ZpyihvCd0w101no=
github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e/go.mod h1:RbqR21r5mrJuqunuUZ/Dhy/avygyECGrLceyNeo4LiM=
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
Expand Down Expand Up @@ -223,8 +223,8 @@ golang.org/x/net v0.0.0-20210505024714-0287a6fb4125/go.mod h1:9nx3DQGgdP8bBQD5qx
golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
golang.org/x/net v0.1.0/go.mod h1:Cx3nUiGt4eDBEyega/BKRp+/AlGL8hYe7U9odMt2Cco=
golang.org/x/net v0.19.0 h1:zTwKpTd2XuCqf8huc7Fo2iSy+4RHPd10s4KzeTnVr1c=
golang.org/x/net v0.19.0/go.mod h1:CfAk/cbD4CthTvqiEl8NpboMuiuOYsAr/7NOjZJtv1U=
golang.org/x/net v0.20.0 h1:aCL9BSgETF1k+blQaYUBx9hJ9LOGP3gAVemcZlf1Kpo=
golang.org/x/net v0.20.0/go.mod h1:z8BVo6PvndSri0LbOE3hAn0apkU+1YvI6E70E9jsnvY=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.5.0 h1:60k92dhOjHxJkrqnwsfl8KuaHbn/5dl0lUPUklKo3qE=
Expand Down