individual identity GET
parent
b5bb38a1fa
commit
9ad2adc510
|
|
@ -9,9 +9,10 @@ router.get('/', async (req, res) => {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
router.get('/:guid', (req, res) => {
|
router.get('/:uid', async (req, res) => {
|
||||||
console.log(req.param.guid);
|
const uid = req.params.uid;
|
||||||
res.json({});
|
const _return = await identity.get(uid);
|
||||||
|
res.json(_return);
|
||||||
})
|
})
|
||||||
|
|
||||||
module.exports = router;
|
module.exports = router;
|
||||||
|
|
@ -12,21 +12,22 @@ async function createIdentity(name) {
|
||||||
await new Promise(res => {
|
await new Promise(res => {
|
||||||
identities.insert({
|
identities.insert({
|
||||||
name,
|
name,
|
||||||
type: 'public',
|
public: pair.exportKey('pkcs1-public-pem'),
|
||||||
key: pair.exportKey('pkcs1-public-pem')
|
private: pair.exportKey('pkcs1-private-pem')
|
||||||
}, res);
|
|
||||||
})
|
|
||||||
await new Promise(res => {
|
|
||||||
identities.insert({
|
|
||||||
name,
|
|
||||||
type: 'private',
|
|
||||||
key: pair.exportKey('pkcs1-private-pem')
|
|
||||||
}, res);
|
}, res);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
async function getIdentity() {
|
async function getIdentity(uid) {
|
||||||
|
return await new Promise((res, rej) => {
|
||||||
|
identities.findOne({
|
||||||
|
_id: uid
|
||||||
|
}, (err, doc) => {
|
||||||
|
if(err || !doc) return rej(err);
|
||||||
|
delete doc.private;
|
||||||
|
res(doc);
|
||||||
|
})
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
async function getAllIdentities() {
|
async function getAllIdentities() {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue