Split authentication hooks into appropriate files#1607
Conversation
| import { userService } from '../../user/user-service'; | ||
| import { accessTokenManager } from './access-token-manager'; | ||
|
|
||
| export async function getProjectAndToken( |
There was a problem hiding this comment.
Moved from community-authentication-hooks.ts
| email, | ||
| password, | ||
| }); | ||
| assertValidEmail(email); |
There was a problem hiding this comment.
Moved from community-authentication-hooks.ts
| import { organizationService } from '../../organization/organization.service'; | ||
| import { userService } from '../../user/user-service'; | ||
|
|
||
| export async function assignDefaultOrganization(user: User): Promise<void> { |
There was a problem hiding this comment.
Moved from community-authentication-hooks.ts
|
|
||
| await expect( | ||
| createUser({ ...baseParams, password: 'abc' }), | ||
| createUser({ ...baseParams, password: 'abcas2esf' }), |
There was a problem hiding this comment.
was this change necessary haha
There was a problem hiding this comment.
It was because the password needs 8 char.
There was a problem hiding this comment.
Pull Request Overview
This PR refactors the authentication service by extracting authentication hooks into dedicated, purpose-specific files. The changes eliminate the hooks pattern in favor of direct function calls, moving core authentication logic into separate modules for user creation, organization assignment, and project context creation.
Key Changes:
- Removed the authentication hooks system (
AuthenticationServiceHooks,communityAuthenticationServiceHooks) and replaced it with direct function calls - Extracted user creation logic into
create-user.tswith comprehensive test coverage - Moved the
Providerenum from internal hooks to the shared package for broader accessibility
Reviewed Changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
packages/shared/src/lib/authentication/model/authentication-type.ts |
Adds new Provider enum to shared package |
packages/shared/src/lib/authentication/dto/sign-up-request.ts |
Removes unused referringUserId field from sign-up request |
packages/shared/src/index.ts |
Exports new authentication-type module |
packages/server/api/test/unit/authentication/new-user/create-user.test.ts |
Adds comprehensive unit tests for user creation functions |
packages/server/api/test/integration/ce/authentication/signup.test.ts |
Removes obsolete imports after hooks removal |
packages/server/api/test/helpers/mocks/authn.ts |
Removes referringUserId from mock sign-up request |
packages/server/api/src/app/user/user-service.ts |
Updates delete method to handle nullable organizationId |
packages/server/api/src/app/database/seeds/seed-admin.ts |
Updates Provider import to use shared package |
packages/server/api/src/app/database/seeds/dev-seeds.ts |
Updates Provider import to use shared package |
packages/server/api/src/app/authentication/new-user/organization-assignment.ts |
Extracts organization assignment logic from hooks |
packages/server/api/src/app/authentication/new-user/create-user.ts |
Extracts user creation logic with validation and rollback handling |
packages/server/api/src/app/authentication/context/create-project-auth-context.ts |
Extracts project context creation from hooks |
packages/server/api/src/app/authentication/authentication.controller.ts |
Updates Provider import to use shared package |
packages/server/api/src/app/authentication/authentication-service/index.ts |
Simplifies authentication service by removing hooks and using extracted functions |
packages/server/api/src/app/authentication/authentication-service/hooks/index.ts |
Removes hooks registration system |
packages/server/api/src/app/authentication/authentication-service/hooks/community-authentication-hooks.ts |
Removes community-specific hooks implementation |
packages/server/api/src/app/authentication/authentication-service/hooks/authentication-service-hooks.ts |
Removes hooks interface and Provider enum |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|



Part of OPS-3003.