-
Notifications
You must be signed in to change notification settings - Fork 1
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
base: master
Are you sure you want to change the base?
Conversation
cdd205f
to
885ad45
Compare
f5431f9
to
ceaeb86
Compare
35909b2
to
18b0e9f
Compare
18b0e9f
to
00c21df
Compare
2cca206
to
da98537
Compare
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 }) { |
There was a problem hiding this comment.
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);
}
src/delete-collection.js
Outdated
}, 400); | ||
}); | ||
const awsRekognitionClass = new Rekognition(ctx.config); | ||
const result = await awsRekognitionClass.deleteCollection(collectionId); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const { statusCode } = await ...
src/face-login.js
Outdated
if (err.statusCode || err.code) { | ||
return response.json(err, err.statusCode || 400); | ||
} | ||
return response.json({ message: 'Authentication fail.' }, 401); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/fail/failed
src/face-login.js
Outdated
} | ||
return res; | ||
}; | ||
const result = await awsRekognitionClass.searchFacesByImage(collectionId, image, s3Bucket, faceMatchThreshold); |
There was a problem hiding this comment.
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 }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Promise.resolve
?
There was a problem hiding this comment.
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
src/face-login.js
Outdated
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) { |
There was a problem hiding this comment.
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
)
There was a problem hiding this comment.
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
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) { |
There was a problem hiding this comment.
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') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
src/verify-face-auth.js
Outdated
.firstOrFail() | ||
.then(verifyUserFaceAuthRegistered) | ||
.catch(() => { | ||
if (result.user_key !== token) { | ||
return response.json({ message: 'Given credentials does not match any user account.' }, 401); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/does/do
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(); |
There was a problem hiding this comment.
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
No description provided.