cypress-firebase icon indicating copy to clipboard operation
cypress-firebase copied to clipboard

feat: more auth functionality

Open KantiKuijk opened this issue 1 year ago • 1 comments

Description

I was in need of some Firebase Auth functions other than those provided by login, logout and getAuthUser, mainly functions like createAuthUser, importAuthUsers and deleteAuthUser(s). Whilst adding those functions I thought, 'Why not add all of them, maybe I need them some day or someone else might?'

I had to rewrite plugin.ts to be more generalised. I was unsure whether to give every auth function it's own task and custom command, or to to something like with callRtdb and callFirestore, where the first argument specified which function actually gets called. Because of the plethora of different arguments needed in the Auth functions, I chose for the former. Also because this was quickest to implement. It does however 'pollute' the tasks and custom commands with lots of them. If the latter approach–where some of the functions get grouped and then work similar to callRtdb/callFirestore–is preferred, I am willing to alter the PR to do so. Another solution to prevent the 'pollution' is to be able to disable custom commands entirely, by adding the possibility to set options.commandNames[someCommandName] to false, which would then skip the Cypress.Commands.add code for that function.

I haven't added tests or made changes to readme.md because I didn't want to put in that effort before knowing this PR has the possibility of getting merged. If so, I would be adding tests and documentation as well.

The auth tasks are:

  • createAuthUser
  • importAuthUsers
  • listAuthUsers
  • getAuthUser (added tenantId param)
  • getAuthUserByEmail
  • getAuthUserByPhoneNumber
  • getAuthUserByProviderUid
  • getAuthUsers
  • updateAuthUser
  • setAuthUserCustomClaims
  • deleteAuthUser
  • deleteAuthUsers
  • createCustomToken
  • createSessionCookie
  • verifyIdToken
  • revokeRefreshTokens
  • generateEmailVerificationLink
  • generatePasswordResetLink
  • generateSignInWithEmailLink
  • generateVerifyAndChangeEmailLink
  • createProviderConfig
  • getProviderConfig
  • listProviderConfigs
  • updateProviderCondig
  • deleteProviderConfig

The custom command are:

  • same as tasks above
  • loginWithEmailAndPassword
  • deleteAllAuthUsers

KantiKuijk avatar Mar 29 '24 12:03 KantiKuijk

Just the optional chaining stuff and adding a note about the new commands to the README, then I think that this should be good to go!

Thanks again for taking the time to make the addition!

prescottprue avatar May 03 '24 05:05 prescottprue

:tada: This PR is included in version 4.1.0 :tada:

The release is available on:

Your semantic-release bot :package::rocket:

github-actions[bot] avatar Jun 11 '24 22:06 github-actions[bot]