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

Update face auth socket #2

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
Open

Update face auth socket #2

wants to merge 11 commits into from

Conversation

eshaibu
Copy link
Contributor

@eshaibu eshaibu commented Jan 19, 2018

No description provided.

@eshaibu eshaibu requested a review from adamwardecki January 19, 2018 08:34
@eshaibu eshaibu force-pushed the ft_collection_config branch from cdd205f to 885ad45 Compare January 22, 2018 06:03
@eshaibu eshaibu force-pushed the ft_collection_config branch from f5431f9 to ceaeb86 Compare February 2, 2018 03:19
@eshaibu eshaibu changed the title Add collectionId to config Update face auth socket Apr 29, 2018
@eshaibu eshaibu force-pushed the ft_collection_config branch 3 times, most recently from 35909b2 to 18b0e9f Compare April 29, 2018 01:26
@eshaibu eshaibu force-pushed the ft_collection_config branch from 18b0e9f to 00c21df Compare April 29, 2018 01:30
@eshaibu eshaibu force-pushed the ft_collection_config branch from 2cca206 to da98537 Compare April 30, 2018 05:34
const awsRekognitionClass = new Rekognition(ctx.config);
const result = await awsRekognitionClass.createCollection(collectionId);
return response.json({ collectionArn: result.CollectionArn, statusCode: result.StatusCode });
} catch ({ ...errors }) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it you are using everything from the response object, it can be simply

catch (error) {
  return response.json(error, 400);
}

}, 400);
});
const awsRekognitionClass = new Rekognition(ctx.config);
const result = await awsRekognitionClass.deleteCollection(collectionId);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

const { statusCode } = await ...

if (err.statusCode || err.code) {
return response.json(err, err.statusCode || 400);
}
return response.json({ message: 'Authentication fail.' }, 401);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/fail/failed

}
return res;
};
const result = await awsRekognitionClass.searchFacesByImage(collectionId, image, s3Bucket, faceMatchThreshold);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

const { FaceMatches }

try {
const faceIds = res.FaceRecords.map(record => record.Face.FaceId);
await awsRekognitionClass.deleteFaces(collectionId, faceIds);
return Promise.reject({ message, statusCode: 400 });
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Promise.resolve ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I want it in outer catch

await users.where('external_image_id', result.FaceMatches[0].Face.ExternalImageId).firstOrFail();
return response.json({ token: user_key, username });
} catch (err) {
if (err.statusCode || err.code) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the err.code is currently not being used in the response (same in face-register.js)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sometime aws error response returns with no statusCode but always with code as part of error response

if (searchFacesResult.FaceMatches.length > 0
&& searchFacesResult.FaceMatches[0].Face.ExternalImageId === external_image_id) {
// delete the user faces index
if (searchFacesResult.FaceMatches.length > 0) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

searchFacesResult.FaceMatches.length > 0 was checked in line 37

@@ -87,7 +58,7 @@ class Rekognition {
}
try {
return {
Bytes: await Rekognition.convertImageToBytes(image)
Bytes: await Buffer.from(image, 'base64')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

.firstOrFail()
.then(verifyUserFaceAuthRegistered)
.catch(() => {
if (result.user_key !== token) {
return response.json({ message: 'Given credentials does not match any user account.' }, 401);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/does/do

message: 'Face auth enabled on user account.', is_face_auth: true
});
};
const result = await users.where('username', username).firstOrFail();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

const { user_key, face_auth } = await

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants