Skip to content

Commit

Permalink
feat(create_driver_trip): forbid without verified driver license
Browse files Browse the repository at this point in the history
  • Loading branch information
Franco Méndez committed Nov 11, 2019
1 parent e56208c commit 3ccddf8
Showing 1 changed file with 27 additions and 27 deletions.
54 changes: 27 additions & 27 deletions create_driver_trip.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,17 +49,17 @@ function alreadyPassed(time) {
return moment(time) < moment();
}

// async function getUser(userId) {
// const params = {
// TableName: UsersTableName,
// Key: {
// user_id: userId
// },
// ProjectionExpression: 'user_verifications.driver_license'
// };
// const data = await dynamoDB.get(params).promise();
// return data.Item;
// }
async function getUser(userId) {
const params = {
TableName: UsersTableName,
Key: {
user_id: userId
},
ProjectionExpression: 'user_verifications.driver_license'
};
const data = await dynamoDB.get(params).promise();
return data.Item;
}

async function getVehicle(vehicleId) {
const params = {
Expand Down Expand Up @@ -128,22 +128,22 @@ exports.handler = async (event) => {
};
}

// const user = await getUser(userId);
// if (
// !user.user_verifications.driver_license.front
// || !user.user_verifications.driver_license.back
// ) {
// return {
// statusCode: 400,
// headers: { 'Access-Control-Allow-Origin': '*' },
// body: JSON.stringify({
// action: 'create',
// success: false,
// resource: 'trip',
// message: 'Missing driver license verification'
// })
// };
// }
const user = await getUser(userId);
if (
!user.user_verifications.driver_license.front
|| !user.user_verifications.driver_license.back
) {
return {
statusCode: 400,
headers: { 'Access-Control-Allow-Origin': '*' },
body: JSON.stringify({
action: 'create',
success: false,
resource: 'trip',
message: 'Missing driver license verification'
})
};
}

const tripId = await createTrip(
userId, vehicleId, availableSeats, etdInfo, routePoints
Expand Down

0 comments on commit 3ccddf8

Please sign in to comment.