-
Notifications
You must be signed in to change notification settings - Fork 89
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
feat: Adds signInFeature type and validation for form fields in EmailPassword Recipe #976
base: master
Are you sure you want to change the base?
Conversation
✅ Deploy Preview for precious-marshmallow-968a81 canceled.
|
✅ Deploy Preview for astounding-pegasus-21c111 canceled.
|
@@ -12,7 +12,7 @@ | |||
* License for the specific language governing permissions and limitations | |||
* under the License. | |||
*/ | |||
export const version = "21.1.0"; | |||
export const version = "21.1.1"; |
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.
This will be a minor (not patch) level change.
validate: field.id === FORM_FIELD_EMAIL_ID ? field.validate : defaultValidator, | ||
optional: false, | ||
}; | ||
function normaliseSignInFormFields(formFields?: TypeInputFormField[]) { |
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.
If done this way, it'd be a breaking change: if someone added an override for their email validators in the sign up config, they'd expect it to be applied here. I'd prefer if we kept it that way as well.
if (field.id === FORM_FIELD_PASSWORD_ID) { | ||
normalisedFormFields.push({ | ||
id: field.id, | ||
validate: field.validate === undefined ? defaultPasswordValidator : field.validate, |
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.
In general, you shouldn't have a validator for the password field during sign-in, since we'd want to check the DB in most cases anyway to prevent cases where a password validation change is preventing people from logging in. I don't mind giving people the option to define this specifically, but by default it should let everything pass.
validate: field.validate === undefined ? defaultPasswordValidator : field.validate, | |
validate: field.validate === undefined ? defaultValidator : field.validate, |
}); | ||
} | ||
if (normalisedFormFields.filter((field) => field.id === FORM_FIELD_PASSWORD_ID).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.
if (normalisedFormFields.filter((field) => field.id === FORM_FIELD_PASSWORD_ID).length === 0) { | |
if (!normalisedFormFields.some((field) => field.id === FORM_FIELD_PASSWORD_ID)) { |
optional: false, | ||
}); | ||
} | ||
if (normalisedFormFields.filter((field) => field.id === FORM_FIELD_EMAIL_ID).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.
if (normalisedFormFields.filter((field) => field.id === FORM_FIELD_EMAIL_ID).length === 0) { | |
if (!normalisedFormFields.some((field) => field.id === FORM_FIELD_EMAIL_ID)) { |
// no password field give by user | ||
normalisedFormFields.push({ | ||
id: FORM_FIELD_PASSWORD_ID, | ||
validate: defaultPasswordValidator, |
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.
validate: defaultPasswordValidator, | |
validate: defaultValidator, |
// no email field give by user | ||
normalisedFormFields.push({ | ||
id: FORM_FIELD_EMAIL_ID, | ||
validate: defaultEmailValidator, |
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.
This should fall back to the (normalized) email field validator for sign-up to avoid breaking apps.
Hi, thanks for your contribution. I think we should be able to get this merged and released next week :) |
Summary of change
Introduce a new
signInFeature
type with validation for form fields, ensuring proper handling of email and password fields. Update related functions to accommodate the new feature. Why? Because my use case needs to send additional data to the SignIn POST endpoint and that made things complicated for the only way to achieve this was to override the SignInPost.Related issues
Test Plan
npm run test. All tests have passed.
Documentation changes
Checklist for important updates
coreDriverInterfaceSupported.json
file has been updated (if needed)lib/ts/version.ts
frontendDriverInterfaceSupported.json
file has been updated (if needed)package.json
package-lock.json
lib/ts/version.ts
npm run build-pretty
recipe/thirdparty/providers/configUtils.ts
file,createProvider
function.git tag
) in the formatvX.Y.Z
, and then find the latest branch (git branch --all
) whoseX.Y
is greater than the latest released tag.add-ts-no-check.js
file to include thatsomeFunc: function () {..}
).exports
inpackage.json
Remaining TODOs for this PR