fix: same ssh key entered multiple times

Users might accidentally past their ssh key multiple times
when they try to register or edit their account.

Convert our of list of keys to a set, removing any double keys.

Signed-off-by: moson <moson@archlinux.org>
This commit is contained in:
moson 2023-07-09 14:52:15 +02:00
parent 225ce23761
commit 5ccfa7c0fd
No known key found for this signature in database
GPG key ID: 4A4760AB4EE15296
2 changed files with 27 additions and 2 deletions

View file

@ -192,9 +192,9 @@ def parse_ssh_key(string: str) -> Tuple[str, str]:
return prefix, key
def parse_ssh_keys(string: str) -> list[Tuple[str, str]]:
def parse_ssh_keys(string: str) -> set[Tuple[str, str]]:
"""Parse a list of SSH public keys."""
return [parse_ssh_key(e) for e in string.strip().splitlines(True) if e.strip()]
return set([parse_ssh_key(e) for e in string.strip().splitlines(True) if e.strip()])
def shell_exec(cmdline: str, cwd: str) -> Tuple[int, str, str]: