-
-
Notifications
You must be signed in to change notification settings - Fork 18
disable user creation in non saas mode #1570
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -14,71 +14,71 @@ | |||||||
|
|
||||||||
| @Injectable() | ||||||||
| export class UserHelperService implements OnModuleInit { | ||||||||
| constructor( | ||||||||
| @InjectRepository(UserEntity) | ||||||||
| private readonly userRepository: Repository<UserEntity>, | ||||||||
| @InjectRepository(CompanyInfoEntity) | ||||||||
| private readonly companyInfoRepository: Repository<CompanyInfoEntity>, | ||||||||
| ) {} | ||||||||
| constructor( | ||||||||
| @InjectRepository(UserEntity) | ||||||||
| private readonly userRepository: Repository<UserEntity>, | ||||||||
| @InjectRepository(CompanyInfoEntity) | ||||||||
| private readonly companyInfoRepository: Repository<CompanyInfoEntity>, | ||||||||
| ) {} | ||||||||
|
|
||||||||
| public buildFoundUserInGroupDs(user: UserEntity): FoundUserInGroupDs { | ||||||||
| return { | ||||||||
| id: user.id, | ||||||||
| email: user.email, | ||||||||
| createdAt: user.createdAt, | ||||||||
| isActive: user.isActive, | ||||||||
| name: user.name, | ||||||||
| suspended: user.suspended, | ||||||||
| externalRegistrationProvider: user.externalRegistrationProvider, | ||||||||
| }; | ||||||||
| } | ||||||||
| public buildFoundUserInGroupDs(user: UserEntity): FoundUserInGroupDs { | ||||||||
| return { | ||||||||
| id: user.id, | ||||||||
| email: user.email, | ||||||||
| createdAt: user.createdAt, | ||||||||
| isActive: user.isActive, | ||||||||
| name: user.name, | ||||||||
| suspended: user.suspended, | ||||||||
| externalRegistrationProvider: user.externalRegistrationProvider, | ||||||||
| }; | ||||||||
| } | ||||||||
|
|
||||||||
| public async buildFoundUserDs(user: UserEntity): Promise<FoundUserDto> { | ||||||||
| const intercomHash = getUserIntercomHash(user.id); | ||||||||
| return { | ||||||||
| id: user.id, | ||||||||
| createdAt: user.createdAt, | ||||||||
| suspended: user.suspended, | ||||||||
| isActive: user.isActive, | ||||||||
| email: user.email, | ||||||||
| intercom_hash: intercomHash, | ||||||||
| name: user.name, | ||||||||
| role: user.role, | ||||||||
| is_2fa_enabled: user.otpSecretKey !== null && user.isOTPEnabled, | ||||||||
| company: user.company ? { id: user.company.id } : null, | ||||||||
| externalRegistrationProvider: user.externalRegistrationProvider, | ||||||||
| show_test_connections: user.showTestConnections, | ||||||||
| }; | ||||||||
| } | ||||||||
| public async buildFoundUserDs(user: UserEntity): Promise<FoundUserDto> { | ||||||||
| const intercomHash = getUserIntercomHash(user.id); | ||||||||
| return { | ||||||||
| id: user.id, | ||||||||
| createdAt: user.createdAt, | ||||||||
| suspended: user.suspended, | ||||||||
| isActive: user.isActive, | ||||||||
| email: user.email, | ||||||||
| intercom_hash: intercomHash, | ||||||||
| name: user.name, | ||||||||
| role: user.role, | ||||||||
| is_2fa_enabled: user.otpSecretKey !== null && user.isOTPEnabled, | ||||||||
| company: user.company ? { id: user.company.id } : null, | ||||||||
| externalRegistrationProvider: user.externalRegistrationProvider, | ||||||||
| show_test_connections: user.showTestConnections, | ||||||||
| }; | ||||||||
| } | ||||||||
|
|
||||||||
| public async onModuleInit(): Promise<void> { | ||||||||
| if (isSaaS()) { | ||||||||
| return; | ||||||||
| } | ||||||||
| const email = (process.env.ADMIN_EMAIL || 'admin@email.local').toLowerCase(); | ||||||||
| const password = | ||||||||
| process.env.ADMIN_PASSWORD || | ||||||||
| (process.env.NODE_ENV === 'test' ? 'test12345' : Encryptor.generateRandomString(10)); | ||||||||
| public async onModuleInit(): Promise<void> { | ||||||||
| if (isSaaS() || process.env.NODE_ENV !== 'test') { | ||||||||
| return; | ||||||||
| } | ||||||||
|
Comment on lines
+55
to
+57
|
||||||||
| const email = (process.env.ADMIN_EMAIL || 'admin@email.local').toLowerCase(); | ||||||||
| const password = | ||||||||
| process.env.ADMIN_PASSWORD || | ||||||||
| (process.env.NODE_ENV === 'test' ? 'test12345' : Encryptor.generateRandomString(10)); | ||||||||
|
|
||||||||
|
Comment on lines
+60
to
62
|
||||||||
| process.env.ADMIN_PASSWORD || | |
| (process.env.NODE_ENV === 'test' ? 'test12345' : Encryptor.generateRandomString(10)); | |
| process.env.ADMIN_PASSWORD || 'test12345'; |
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.
The modified condition contradicts the PR title "disable user creation in non saas mode". The new logic
if (isSaaS() || process.env.NODE_ENV !== 'test')only allows admin user creation in test mode for non-SaaS deployments. This means production self-hosted (non-SaaS) instances will NOT automatically create an admin user on startup.This appears to be a critical breaking change for self-hosted production deployments. Previously, the admin user was created automatically for all non-SaaS instances. Now it will only be created in test environments.
If the intent is to disable automatic user creation in production non-SaaS mode and rely on the CreateInitialUserUseCase endpoint for user creation instead, this should be clarified in the PR description. However, this would be a breaking change that requires migration documentation.