Skip to content

Update face auth socket - #2

Open
eshaibu wants to merge 11 commits into
masterfrom
ft_collection_config
Open

Update face auth socket#2
eshaibu wants to merge 11 commits into
masterfrom
ft_collection_config

Conversation

@eshaibu

@eshaibu eshaibu commented Jan 19, 2018

Copy link
Copy Markdown
Contributor

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
Comment thread src/create-collection.js Outdated
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
Copy Markdown
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);
}

Comment thread src/delete-collection.js Outdated
}, 400);
});
const awsRekognitionClass = new Rekognition(ctx.config);
const result = await awsRekognitionClass.deleteCollection(collectionId);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

const { statusCode } = await ...

Comment thread src/face-login.js Outdated
if (err.statusCode || err.code) {
return response.json(err, err.statusCode || 400);
}
return response.json({ message: 'Authentication fail.' }, 401);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

s/fail/failed

Comment thread src/face-login.js Outdated
}
return res;
};
const result = await awsRekognitionClass.searchFacesByImage(collectionId, image, s3Bucket, faceMatchThreshold);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

const { FaceMatches }

Comment thread src/face-register.js
try {
const faceIds = res.FaceRecords.map(record => record.Face.FaceId);
await awsRekognitionClass.deleteFaces(collectionId, faceIds);
return Promise.reject({ message, statusCode: 400 });

Copy link
Copy Markdown
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
Copy Markdown
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

Comment thread src/face-login.js
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
Copy Markdown
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
Copy Markdown
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

Comment thread src/remove-face-auth.js Outdated
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
Copy Markdown
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

Comment thread src/utils/Rekognition.js
try {
return {
Bytes: await Rekognition.convertImageToBytes(image)
Bytes: await Buffer.from(image, 'base64')

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

👍

Comment thread src/verify-face-auth.js Outdated
.then(verifyUserFaceAuthRegistered)
.catch(() => {
if (result.user_key !== token) {
return response.json({ message: 'Given credentials does not match any user account.' }, 401);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

s/does/do

Comment thread src/verify-face-auth.js Outdated
message: 'Face auth enabled on user account.', is_face_auth: true
});
};
const result = await users.where('username', username).firstOrFail();

Copy link
Copy Markdown
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