-
Notifications
You must be signed in to change notification settings - Fork 389
Adds ability to import users with phone second factors. #699
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
Conversation
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.
Looks pretty good. Just a few suggestions for improvement.
src/auth/auth-api-request.ts
Outdated
); | ||
} | ||
if (typeof request.displayName !== 'undefined' && | ||
typeof request.displayName !== 'string') { |
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.
!validator.isString()
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.
done
src/auth/auth-api-request.ts
Outdated
@@ -381,6 +442,15 @@ function validateCreateEditRequest(request: any, uploadAccountRequest: boolean = | |||
validateProviderUserInfo(providerUserInfoEntry); | |||
}); | |||
} | |||
// mfaInfo has to be an array of valid AuthFactorInfo requests. | |||
if (typeof request.mfaInfo !== 'undefined' && |
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.
May be this is clearer:
if (request.mfaInfo) {
if (!validator.isArray(request.mfaInfo) {
throw ...
}
request.mfaInfo.forEach...
}
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.
done
let enrolledAt; | ||
if (typeof multiFactorInfo.enrollmentTime !== 'undefined') { | ||
if (validator.isUTCDateString(multiFactorInfo.enrollmentTime)) { | ||
enrolledAt = new Date(multiFactorInfo.enrollmentTime).toISOString(); |
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.
Is there a timezone conversion happening here? Perhaps add a comment.
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.
Added comment.
phoneNumber: '+16505557348', | ||
displayName: 'Spouse\'s phone number', | ||
factorId: 'phone', | ||
enrollmentTime: 'invalid', |
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 expected this to throw. How is it getting silently ignored?
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.
Actually it only gets ignored when building the request. The client side errors are cached and will be injected in the response alongside server side response. Check test should return the expected response for import with client side errors
. I added a test for this.
uid: 'enrolledSecondFactor1', | ||
secret: 'SECRET', | ||
displayName: 'Google Authenticator on personal phone', | ||
factorId: 'totp', |
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.
Expected to throw.
It looks like there's some pre-existing logic in the UserImportBuilder to handle these errors, and ignore them. May be we should at least log a warning when this happens, so a simple typo in the user code doesn't go completely unnoticed.
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.
Same here. The client side errors are cached and will be injected in the response alongside server side response. Check test should return the expected response for import with client side errors
. I added a test for this too.
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.
Thanks. LGTM 👍
Thanks for the quick and helpful review! |
WIP: Adds ability to import users with phone second factors.