Update face auth socket - #2
Conversation
cdd205f to
885ad45
Compare
f5431f9 to
ceaeb86
Compare
35909b2 to
18b0e9f
Compare
18b0e9f to
00c21df
Compare
2cca206 to
da98537
Compare
| 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.
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); |
There was a problem hiding this comment.
const { statusCode } = await ...
| if (err.statusCode || err.code) { | ||
| return response.json(err, err.statusCode || 400); | ||
| } | ||
| return response.json({ message: 'Authentication fail.' }, 401); |
| } | ||
| return res; | ||
| }; | ||
| const result = await awsRekognitionClass.searchFacesByImage(collectionId, image, s3Bucket, faceMatchThreshold); |
There was a problem hiding this comment.
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.
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) { |
There was a problem hiding this comment.
the err.code is currently not being used in the response (same in face-register.js)
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
searchFacesResult.FaceMatches.length > 0 was checked in line 37
| try { | ||
| return { | ||
| Bytes: await Rekognition.convertImageToBytes(image) | ||
| Bytes: await Buffer.from(image, 'base64') |
| .then(verifyUserFaceAuthRegistered) | ||
| .catch(() => { | ||
| if (result.user_key !== token) { | ||
| return response.json({ message: 'Given credentials does not match any user account.' }, 401); |
| 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.
const { user_key, face_auth } = await
No description provided.