Imrpove profile page

This commit is contained in:
Yarmo Mackenbach 2020-06-26 17:52:01 +02:00
parent e5a3344813
commit a3abf17937
2 changed files with 41 additions and 10 deletions

View file

@ -165,7 +165,30 @@ async function verifyProofs(opts) {
// Display feedback // Display feedback
elRes.innerHTML = feedback; elRes.innerHTML = feedback;
}; }
async function displayProfile(opts) {
let keyData = await fetchKeys(opts);
let userData = keyData.user.user.userId;
let feedback = "", notation, isVerified, verifications = [];
document.body.querySelector('#profile--name').innerHTML = userData.name;
document.body.querySelector('#profile--email').innerHTML = userData.email;
for (var i = 0; i < keyData.notations.length; i++) {
notation = keyData.notations[i];
if (!(notation[0] == "proof@keyoxide.org" || notation[0] == "proof@metacode.biz")) { continue; }
verifications.push(await verifyProof(notation[1], keyData.fingerprint));
}
// Generate feedback
for (var i = 0; i < verifications.length; i++) {
feedback += `${verifications[i].type}: <a href="${verifications[i].url}">${verifications[i].display}</a>: ${verifications[i].isVerified}<br>`;
}
// Display feedback
document.body.querySelector('#profile--proofs').innerHTML = feedback;
}
async function verifyProof(url, fingerprint) { async function verifyProof(url, fingerprint) {
// Init // Init
@ -385,8 +408,9 @@ async function fetchKeys(opts) {
// General purpose // General purpose
let elFormVerify = document.body.querySelector("#form-verify"), let elFormVerify = document.body.querySelector("#form-verify"),
elFormEncrypt = document.body.querySelector("#form-encrypt"); elFormEncrypt = document.body.querySelector("#form-encrypt"),
elFormProofs = document.body.querySelector("#form-proofs"); elFormProofs = document.body.querySelector("#form-proofs"),
elProfileUid = document.body.querySelector("#profileUid");
if (elFormVerify) { if (elFormVerify) {
elFormVerify.onsubmit = function (evt) { elFormVerify.onsubmit = function (evt) {
@ -474,3 +498,12 @@ if (elFormProofs) {
verifyProofs(opts); verifyProofs(opts);
}; };
} }
if (elProfileUid) {
let profileUid = elProfileUid.innerHTML;
let opts = {
input: profileUid,
mode: "hkp"
}
displayProfile(opts);
}

View file

@ -12,19 +12,17 @@
<header> <header>
<div class="container"> <div class="container">
<a href="/">Keyoxide</a> <a href="/">Keyoxide</a>
<div class="spacer"></div>
<nav>
<a href="/verify">verify</a>
<a href="/encrypt">encrypt</a>
<a href="/proofs">proofs</a>
</nav>
</div> </div>
</header> </header>
<div class="container"> <div class="container">
<h1>Profile</h1> <h1>Profile</h1>
<div class="content"> <div class="content">
<h3 class="profile_uid">%UID%</h3> <h3></h3>
<p>Input: <span id="profileUid">%UID%</span></p>
<p>Name: <span id="profile--name"></span></p>
<p>Email address: <span id="profile--email">/span></p>
<p>Proofs: <span id="profile--proofs">/span></p>
</div> </div>
<footer> <footer>