Skip to content

Update password policy in reset password flow when the password does not meet the backend requirements #7434

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

Merged
merged 9 commits into from
Jul 14, 2023

Conversation

ch5zzy
Copy link
Contributor

@ch5zzy ch5zzy commented Jul 10, 2023

Update the cached password policy when the reset password flow (confirmPasswordReset) receives a PASSWORD_DOES_NOT_MEET_REQUIREMENTS error.

@changeset-bot
Copy link

changeset-bot bot commented Jul 10, 2023

⚠️ No Changeset found

Latest commit: 70383b1

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@google-oss-bot
Copy link
Contributor

google-oss-bot commented Jul 10, 2023

Size Report 1

Affected Products

  • @firebase/auth

    TypeBase (d40ca7d)Merge (9b4251c)Diff
    browser175 kB176 kB+268 B (+0.2%)
    cordova204 kB204 kB+647 B (+0.3%)
    esm5229 kB229 kB+647 B (+0.3%)
    main173 kB174 kB+671 B (+0.4%)
    module175 kB176 kB+268 B (+0.2%)
    react-native188 kB189 kB+679 B (+0.4%)
  • @firebase/auth/cordova

    TypeBase (d40ca7d)Merge (9b4251c)Diff
    browser204 kB204 kB+647 B (+0.3%)
    module204 kB204 kB+647 B (+0.3%)
  • @firebase/auth/internal

    TypeBase (d40ca7d)Merge (9b4251c)Diff
    browser186 kB186 kB+268 B (+0.1%)
    esm5242 kB243 kB+647 B (+0.3%)
    main209 kB210 kB+681 B (+0.3%)
    module186 kB186 kB+268 B (+0.1%)
  • @firebase/auth/react-native

    TypeBase (d40ca7d)Merge (9b4251c)Diff
    browser188 kB189 kB+679 B (+0.4%)
    module188 kB189 kB+679 B (+0.4%)
  • firebase

    TypeBase (d40ca7d)Merge (9b4251c)Diff
    firebase-auth-compat.js136 kB136 kB+148 B (+0.1%)
    firebase-auth-cordova.js152 kB152 kB+464 B (+0.3%)
    firebase-auth-react-native.js164 kB164 kB+508 B (+0.3%)
    firebase-auth.js130 kB130 kB+150 B (+0.1%)
    firebase-compat.js777 kB777 kB+148 B (+0.0%)

Test Logs

  1. https://storage.googleapis.com/firebase-sdk-metric-reports/DAgAnPaNgF.html

@google-oss-bot
Copy link
Contributor

google-oss-bot commented Jul 10, 2023

Size Analysis Report 1

Affected Products

  • @firebase/auth

    • confirmPasswordReset

      Size

      TypeBase (d40ca7d)Merge (9b4251c)Diff
      size38.6 kB38.8 kB+221 B (+0.6%)
      size-with-ext-deps59.3 kB59.6 kB+221 B (+0.4%)

      Dependency

      TypeBase (d40ca7d)Merge (9b4251c)Diff
      functions

      57 dependencies

      _addTidIfNecessary
      _assert
      _castAuth
      _createError
      _emulatorUrl
      _errorWithCustomMessage
      _fail
      _getBrowserName
      _getClientVersion
      _getCurrentScheme
      _getFinalTarget
      _getInstance
      _getPasswordPolicy
      _getUserLanguage
      _initializeAuthInstance
      _isAndroid
      _isBlackBerry
      _isChromeIOS
      _isFirefox
      _isHttpOrHttps
      _isIEMobile
      _isOnline
      _isSafari
      _isWebOS
      _loadJS
      _logError
      _logWarn
      _logoutIfInvalidated
      _makeTaggedError
      _parseToken
      _performApiRequest
      _performFetchWithErrorHandling
      _persistenceKeyName
      _prodErrorMap
      _reloadWithoutSaving
      _tokenExpiresIn
      assertStringOrUndefined
      confirmPasswordReset
      createErrorInternal
      debugAssert
      debugFail
      deleteAccount
      extractProviderData
      getAccountInfo
      getIdTokenResult
      getRecaptchaConfig
      getScriptParentElement
      getVersionForPlatform
      isEnterprise
      isUserInvalidated
      mergeProviderData
      registerAuth
      reload
      requestStsToken
      resetPassword
      secondsStringToMilliseconds
      utcTimestampToDateString

      58 dependencies

      _addTidIfNecessary
      _assert
      _castAuth
      _createError
      _emulatorUrl
      _errorWithCustomMessage
      _fail
      _getBrowserName
      _getClientVersion
      _getCurrentScheme
      _getFinalTarget
      _getInstance
      _getPasswordPolicy
      _getUserLanguage
      _initializeAuthInstance
      _isAndroid
      _isBlackBerry
      _isChromeIOS
      _isFirefox
      _isHttpOrHttps
      _isIEMobile
      _isOnline
      _isSafari
      _isWebOS
      _loadJS
      _logError
      _logWarn
      _logoutIfInvalidated
      _makeTaggedError
      _parseToken
      _performApiRequest
      _performFetchWithErrorHandling
      _persistenceKeyName
      _prodErrorMap
      _reloadWithoutSaving
      _tokenExpiresIn
      assertStringOrUndefined
      confirmPasswordReset
      createErrorInternal
      debugAssert
      debugFail
      deleteAccount
      extractProviderData
      getAccountInfo
      getIdTokenResult
      getRecaptchaConfig
      getScriptParentElement
      getVersionForPlatform
      isEnterprise
      isUserInvalidated
      mergeProviderData
      recachePasswordPolicy
      registerAuth
      reload
      requestStsToken
      resetPassword
      secondsStringToMilliseconds
      utcTimestampToDateString

      + recachePasswordPolicy

    • createUserWithEmailAndPassword

      Size

      TypeBase (d40ca7d)Merge (9b4251c)Diff
      size40.4 kB40.5 kB+51 B (+0.1%)
      size-with-ext-deps61.2 kB61.3 kB+51 B (+0.1%)

      Dependency

      TypeBase (d40ca7d)Merge (9b4251c)Diff
      functions

      60 dependencies

      _addTidIfNecessary
      _assert
      _castAuth
      _createError
      _emulatorUrl
      _errorWithCustomMessage
      _fail
      _getBrowserName
      _getClientVersion
      _getCurrentScheme
      _getFinalTarget
      _getInstance
      _getPasswordPolicy
      _getUserLanguage
      _initializeAuthInstance
      _isAndroid
      _isBlackBerry
      _isChromeIOS
      _isFirefox
      _isHttpOrHttps
      _isIEMobile
      _isOnline
      _isSafari
      _isWebOS
      _loadJS
      _logError
      _logWarn
      _logoutIfInvalidated
      _makeTaggedError
      _parseToken
      _performApiRequest
      _performFetchWithErrorHandling
      _performSignInRequest
      _persistenceKeyName
      _prodErrorMap
      _reloadWithoutSaving
      _tokenExpiresIn
      assertStringOrUndefined
      createErrorInternal
      createUserWithEmailAndPassword
      debugAssert
      debugFail
      deleteAccount
      extractProviderData
      getAccountInfo
      getIdTokenResult
      getRecaptchaConfig
      getScriptParentElement
      getVersionForPlatform
      injectRecaptchaFields
      isEnterprise
      isUserInvalidated
      mergeProviderData
      providerIdForResponse
      registerAuth
      reload
      requestStsToken
      secondsStringToMilliseconds
      signUp
      utcTimestampToDateString

      61 dependencies

      _addTidIfNecessary
      _assert
      _castAuth
      _createError
      _emulatorUrl
      _errorWithCustomMessage
      _fail
      _getBrowserName
      _getClientVersion
      _getCurrentScheme
      _getFinalTarget
      _getInstance
      _getPasswordPolicy
      _getUserLanguage
      _initializeAuthInstance
      _isAndroid
      _isBlackBerry
      _isChromeIOS
      _isFirefox
      _isHttpOrHttps
      _isIEMobile
      _isOnline
      _isSafari
      _isWebOS
      _loadJS
      _logError
      _logWarn
      _logoutIfInvalidated
      _makeTaggedError
      _parseToken
      _performApiRequest
      _performFetchWithErrorHandling
      _performSignInRequest
      _persistenceKeyName
      _prodErrorMap
      _reloadWithoutSaving
      _tokenExpiresIn
      assertStringOrUndefined
      createErrorInternal
      createUserWithEmailAndPassword
      debugAssert
      debugFail
      deleteAccount
      extractProviderData
      getAccountInfo
      getIdTokenResult
      getRecaptchaConfig
      getScriptParentElement
      getVersionForPlatform
      injectRecaptchaFields
      isEnterprise
      isUserInvalidated
      mergeProviderData
      providerIdForResponse
      recachePasswordPolicy
      registerAuth
      reload
      requestStsToken
      secondsStringToMilliseconds
      signUp
      utcTimestampToDateString

      + recachePasswordPolicy

Test Logs

  1. https://storage.googleapis.com/firebase-sdk-metric-reports/wJU35hbMfS.html

ch5zzy and others added 6 commits July 13, 2023 14:44
* Define internal password policy typings
* Define PasswordPolicyImpl

* Add PasswordPolicyCustomStrengthOptions internal typing
* Update Auth to use PasswordPolicyImpl for validation

* Rename _getPasswordPolicy to _getPasswordPolicyInternal
…tch API proposal (#7456)

* Implement validatePassword

* Fix allowedNonAlphanumericCharacters typing to match API proposal
@ch5zzy ch5zzy requested a review from Xiaoshouzi-gh July 13, 2023 22:26
@ch5zzy ch5zzy marked this pull request as ready for review July 13, 2023 22:26
@ch5zzy ch5zzy requested review from lisajian, prameshj, renkelvin, sam-gc and a team as code owners July 13, 2023 22:26
@ch5zzy ch5zzy changed the title Update password policy in reset password flow Update password policy in reset password flow when the password does not meet the backend requirements Jul 13, 2023
Copy link

@Xiaoshouzi-gh Xiaoshouzi-gh left a comment

Choose a reason for hiding this comment

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

Mostly LTGM.
There are some strings that show up more than once in the test, please consider putting them to a constant.

@ch5zzy
Copy link
Contributor Author

ch5zzy commented Jul 14, 2023

The strings that are duplicated are used in test cases that I didn't write, but I'll extract the strings that I also use into global constants to help clean up code style since these tests should have done this originally.

@ch5zzy ch5zzy merged commit 1025840 into password-policy Jul 14, 2023
@ch5zzy ch5zzy deleted the update-policy-in-reset-password-flow branch July 14, 2023 18:59
@firebase firebase locked and limited conversation to collaborators Aug 14, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants