-
-
Notifications
You must be signed in to change notification settings - Fork 0
refactor(identity-provider): use service hooks and resolvers #9033
Conversation
packages/server-core/src/user/identity-provider/identity-provider.hooks.ts
Outdated
Show resolved
Hide resolved
packages/server-core/src/user/identity-provider/identity-provider.hooks.ts
Outdated
Show resolved
Hide resolved
packages/server-core/src/user/identity-provider/identity-provider.hooks.ts
Outdated
Show resolved
Hide resolved
packages/server-core/src/user/identity-provider/identity-provider.hooks.ts
Outdated
Show resolved
Hide resolved
packages/server-core/src/user/identity-provider/identity-provider.hooks.ts
Outdated
Show resolved
Hide resolved
packages/server-core/src/user/identity-provider/identity-provider.hooks.ts
Outdated
Show resolved
Hide resolved
Changed order of identity-provider create hooks. validateAuthParams needs to occur after createNewUser, or else it won't have a userId to act on.
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.
There's some bugs surrounding validateAuthParams and createNewUser. As it currently stands, creating a guest user is failing because validateAuthParams never resolves to a userId; there's no authentication present when creating a guest user, and there's no userId on the request data because requests to create a new guest user by definition don't have a userId already.
I tried moving validateAuthParams to the end of the array of create hooks, but then requests to create new identity-providers with a userId on the request data are causing createNewUser to trigger, as there's no existingUser object on the context when it gets to that check. This makes new users when it shouldn't, and the identity-providers get associated with those new guest users by mistake.
I changed a few of the test checks to not just ensure that a userId is present but that it matches the userId passed as part of the request. If the hook logic is altered so that all tests pass, I think that will resolve the current issues.
You are right. I totally missed this scenario due to an incorrect arrangement of hooks. I have changed the The tests are now passing! |
Summary
🤖 Generated by Copilot at 0ff62e2
This pull request refactors and simplifies the identity-provider service and its related files, using hooks, KnexService, and removing unused or redundant code. It also implements the invite code feature for users, using the getFreeInviteCode function and modifying the user resolvers.
References
closes part of #8871
Explanation
🤖 Generated by Copilot at 0ff62e2
🤖 Generated by Copilot at 0ff62e2
QA Steps
List any additional steps required to QA the changes of this PR, as well as any supplemental images or videos.
Checklist