fix(fastapi): fix PGP Key Fingerprint display for account/show.html

There's a space between every 4 characters in the fingerprint
in PHP; we were missing it in FastAPI. This commit fixes that
inconsistency.

Signed-off-by: Kevin Morris <kevr@0cost.org>
This commit is contained in:
Kevin Morris 2021-12-03 23:40:16 -08:00
parent 522177e813
commit bfa916c7b2
No known key found for this signature in database
GPG key ID: F7E46DED420788F3
2 changed files with 11 additions and 2 deletions

View file

@ -432,7 +432,16 @@ async def account(request: Request, username: str):
if not request.user.is_authenticated(): if not request.user.is_authenticated():
return render_template(request, "account/show.html", context, return render_template(request, "account/show.html", context,
status_code=HTTPStatus.UNAUTHORIZED) status_code=HTTPStatus.UNAUTHORIZED)
context["user"] = get_user_by_name(username)
# Get related User record, if possible.
user = get_user_by_name(username)
context["user"] = user
# Format PGPKey for display with a space between each 4 characters.
k = user.PGPKey or str()
context["pgp_key"] = " ".join([k[i:i + 4] for i in range(0, len(k), 4)])
# Render the template.
return render_template(request, "account/show.html", context) return render_template(request, "account/show.html", context)

View file

@ -46,7 +46,7 @@
</tr> </tr>
<tr> <tr>
<th>{% trans %}PGP Key Fingerprint{% endtrans %}:</th> <th>{% trans %}PGP Key Fingerprint{% endtrans %}:</th>
<td>{{ user.PGPKey or '' }}</td> <td>{{ pgp_key }}</td>
</tr> </tr>
<tr> <tr>
<th>{% trans %}Status{% endtrans %}:</th> <th>{% trans %}Status{% endtrans %}:</th>