Compare commits

...

3 Commits

Author SHA1 Message Date
Wiktor Kwapisiewicz
27c86a3ea7 profiles: Display more info in noscript mode 2020-08-19 11:17:33 +02:00
Wiktor Kwapisiewicz
e3b839b9e0 profiles: Return profile page for regular search results too 2020-08-19 10:51:08 +02:00
Wiktor Kwapisiewicz
9b44868e27 profiles: Support both e-mail and fingerprint queries 2020-08-19 10:50:42 +02:00
3 changed files with 20 additions and 4 deletions

View File

@@ -36,8 +36,9 @@
return null;
}
const email = location.href.split('/').pop();
const keyUrl = "/vks/v1/by-email/" + email;
const query = decodeURIComponent(location.href.split(/[=/]/).pop());
const type = query.indexOf('@') == -1 ? 'fingerprint' : 'email';
const keyUrl = `/vks/v1/by-${type}/${query}`;
const response = await fetch(keyUrl);
const armor = await response.text();
const key = (await openpgp.key.readArmored(armor)).keys[0];
@@ -62,6 +63,7 @@
// grab avatar from MD5 of primary user's e-mail address
const util = openpgp.util;
const email = primaryUser.user.userId.email;
const digest = await openpgp.crypto.hash.md5(util.str_to_Uint8Array(email));
const profileHash = util.str_to_hex(util.Uint8Array_to_str(digest));

View File

@@ -59,7 +59,21 @@
<script src="/assets/openpgp.min.js" integrity="sha384-/N1ZJTH7aZFvzCM9Jy9dQmQzroYQpB5L2qrNPgYpg1/tbwVDvaqWwGHfHeFhSpcn" crossorigin="anonymous"></script>
<script src="/assets/js/proofs.js"></script>
<noscript>This page contents are generated and validated by JavaScript code running in your browser.
Please enable JavaScript to see user's profile page.</noscript>
Please enable JavaScript to see user's profile page.
{{#with page}}
<p>
{{ text "We found an entry for <span class=\"email\">{{ query }}</span>." rerender }}
</p>
<p>
<a href="{{ ../base_uri }}/vks/v1/by-fingerprint/{{ fpr }}">{{ ../base_uri }}/vks/v1/by-fingerprint/{{ fpr }}</a>
</p>
<p>
{{text "<strong>Hint:</strong> It's more convenient to use <span class=\"brand\">keys.openpgp.org</span> from your OpenPGP software.<br /> Take a look at our <a href=\"/about/usage\">usage guide</a> for details." }}
</p>
{{/with}}
</noscript>
<div class="spacer"></div>
</div>
<div class="attribution">

View File

@@ -287,7 +287,7 @@ fn key_to_response(
fpr: fp.to_string(),
};
MyResponse::ok("found", context)
MyResponse::ok("found-profile", context)
}