Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add confirmation route and handler, relates to issue #11 #13

Merged
merged 2 commits into from
Feb 8, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
"hapi": "^15.2.0",
"inert": "^4.0.2",
"joi": "^10.0.1",
"vision": "^4.1.0"
"vision": "^4.1.0",
"yoti-node-sdk": "^1.0.2"
},
"engines": {
"node": "6.9.1"
Expand Down
6 changes: 4 additions & 2 deletions src/routes.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
const { homeRoute } = require('./handlers/home.js');
const { staticRoute } = require('./handlers/static.js');
const { homeRoute } = require('./routes/home.js');
const { staticRoute } = require('./routes/static.js');
const { confirmationRoute } = require('./routes/confirmation.js');

const routes = [
confirmationRoute,
homeRoute,
staticRoute
];
Expand Down
32 changes: 32 additions & 0 deletions src/routes/confirmation.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
const Yoti = require('yoti-node-sdk');
const Path = require('path');
const Fs = require('fs');

const sdkId = "06f10391-1f16-4e1c-af6c-d6cd6a8714af";
const yotiPem = Fs.readFileSync(Path.join(__dirname, '../keys/yoti.pem'));
const yotiClient = new Yoti(sdkId, yotiPem);

const confirmationHandler = (request, reply) => {
const token = request.query.token;
if(!token) {
reply("no token!")
return
}
const promise = yotiClient.getActivityDetails(token);
promise.then((activityDetails) => {
const userId = activityDetails.getUserId();
const profile = activityDetails.getUserProfile();
reply(profile);
})
};

const confirmationRoute = {
method: 'GET',
path: '/confirmation',
handler: confirmationHandler
};

module.exports = {
confirmationRoute,
confirmationHandler
}
File renamed without changes.
File renamed without changes.