Title: Calling Firebase `validatePassword` outside of an Injection context · Issue #3614 · angular/angularfire · GitHub
Open Graph Title: Calling Firebase `validatePassword` outside of an Injection context · Issue #3614 · angular/angularfire
X Title: Calling Firebase `validatePassword` outside of an Injection context · Issue #3614 · angular/angularfire
Description: Is the running outside of injection context warning legitimate when using validatePassword? My code: import { EnvironmentInjector, inject, runInInjectionContext } from '@angular/core'; import { Auth, validatePassword } from '@angular/fir...
Open Graph Description: Is the running outside of injection context warning legitimate when using validatePassword? My code: import { EnvironmentInjector, inject, runInInjectionContext } from '@angular/core'; import { Aut...
X Description: Is the running outside of injection context warning legitimate when using validatePassword? My code: import { EnvironmentInjector, inject, runInInjectionContext } from '@angular/core'; impo...
Opengraph URL: https://github.com/angular/angularfire/issues/3614
X: @github
Domain: github.com
IPv4 address: 140.82.112.3
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Calling Firebase `validatePassword` outside of an Injection context","articleBody":"Is the running outside of injection context warning legitimate when using `validatePassword`?\n\nMy code:\n\n```ts\nimport { EnvironmentInjector, inject, runInInjectionContext } from '@angular/core';\nimport { Auth, validatePassword } from '@angular/fire/auth';\nimport type { PasswordValidationStatus } from '@angular/fire/auth';\nimport type { AbstractControl, AsyncValidatorFn, ValidationErrors } from '@angular/forms';\n\nimport { getPasswordControlValue } from './util';\n\n/**\n * Validate against the Firebase Project Authentication Password Policy.\n *\n * Note: at this time there is no actual need for this because the policy only enforces length and\n * other Validators already check for that. However it is nice to know how to do this.\n */\nexport const passwordFirebaseValidator = (): AsyncValidatorFn => {\n const auth: Auth = inject(Auth);\n const environmentInjector = inject(EnvironmentInjector);\n\n return async (control: AbstractControl\u003cunknown>): Promise\u003cValidationErrors | null> => {\n const value = getPasswordControlValue(control);\n\n // Like Validators.email, rely on Validators.required to check for blank passwords.\n if (value == undefined) {\n return null; // eslint-disable-line unicorn/no-null -- ValidatorFn returns null\n }\n\n const { passwordPolicy: _, ...status } = await runInInjectionContext(\n environmentInjector,\n async (): Promise\u003cPasswordValidationStatus> => validatePassword(auth, value),\n );\n\n return status.isValid ? null : { firebasevalidator: status }; // eslint-disable-line unicorn/no-null\n };\n};\n```\n\nI added `EnvironmentInjector` and `runInInjectionContext` and that got rid of the warning, but is all this necessary? It would be nice if validation was simplier. ","author":{"url":"https://github.com/rgant","@type":"Person","name":"rgant"},"datePublished":"2025-01-22T00:18:36Z","url":"https://github.com/angular/angularfire/issues/3614"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:18e005dd-be53-7d94-eb31-3f9f8d77a2ef |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 9A3E:7189C:2D0E864:3BD596F:6B03602E |
| html-safe-nonce | 3b54e3211de97be7be11d5dcdc7667aaa79dcb11c739be33b69e43710fb665ca |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5QTNFOjcxODlDOjJEMEU4NjQ6M0JENTk2Rjo2QjAzNjAyRSIsInZpc2l0b3JfaWQiOiIxMDcyMzAwMDY0MzgyMjM5MTgiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | ff49f421e2c5dd344540b18a1242ab7c5afbe61def78bc52807c55e756956c75 |
| hovercard-subject-tag | issue:2803078738 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/angular/angularfire/3614/issue_layout |
| twitter:image | https://opengraph.githubassets.com/83d9d245548a9321c9e315abf88f9b477d369a13a6d08074af70952f41de53bb/angular/angularfire/issues/3614 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/83d9d245548a9321c9e315abf88f9b477d369a13a6d08074af70952f41de53bb/angular/angularfire/issues/3614 |
| og:image:alt | Is the running outside of injection context warning legitimate when using validatePassword? My code: import { EnvironmentInjector, inject, runInInjectionContext } from '@angular/core'; import { Aut... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | rgant |
| hostname | github.com |
| expected-hostname | github.com |
| None | 87e774ee7c6b3bee0490394e4d3e57ec9dbc956f74b87ea685dc8996c1676456 |
| turbo-cache-control | no-preview |
| go-import | github.com/angular/angularfire git https://github.com/angular/angularfire.git |
| octolytics-dimension-user_id | 139426 |
| octolytics-dimension-user_login | angular |
| octolytics-dimension-repository_id | 49453413 |
| octolytics-dimension-repository_nwo | angular/angularfire |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 49453413 |
| octolytics-dimension-repository_network_root_nwo | angular/angularfire |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 423dbb54c5e7bfecc838eb387c1435eb3d0e760d |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
| Server | github.com |
| Content-Type | text/html; charset=utf-8 |
| Cache-Control | max-age=0, private, must-revalidate |
Viewport: width=device-width