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