-
Notifications
You must be signed in to change notification settings - Fork 10
feat: add support for dynamic access group configuration and synchron… #2226
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
base: dev
Are you sure you want to change the base?
Changes from 1 commit
b8f3152
776ce32
2c25305
aef4a3f
862d339
b26956c
f97ea5d
69cd456
3d2bdfd
820fd57
af89569
c330ac5
b1df0fa
5782890
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 | ||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -52,7 +52,10 @@ export class AuthService implements OnModuleInit { | |||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| async onModuleInit(): Promise<void> { | ||||||||||||||||||||||||||||||||||
| await this.affiliationGroupService.createAccessGroups(this.config); | ||||||||||||||||||||||||||||||||||
| await this.affiliationGroupService.syncAccessGroups( | ||||||||||||||||||||||||||||||||||
| this.config, | ||||||||||||||||||||||||||||||||||
| this.userRepository, | ||||||||||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||||||||||
|
Comment on lines
+55
to
+58
|
||||||||||||||||||||||||||||||||||
| await this.affiliationGroupService.syncAccessGroups( | |
| this.config, | |
| this.userRepository, | |
| ); | |
| logger.info('Starting access group sync in background during module initialization'); | |
| void this.affiliationGroupService | |
| .syncAccessGroups(this.config, this.userRepository) | |
| .then(() => { | |
| logger.info('Access group sync completed'); | |
| }) | |
| .catch((error: unknown) => { | |
| logger.error( | |
| 'Access group sync failed during module initialization', | |
| error, | |
| ); | |
| }); |
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.
createAccessGroups is redundant before syncAccessGroups
syncAccessGroups already upserts every group from the config in its step 1, so the preceding createAccessGroups call performs duplicate lookups for every configured group. Removing it avoids the unnecessary round-trips.
Prompt To Fix With AI
This is a comment left during a code review.
Path: backend/src/services/auth.service.ts
Line: 54-59
Comment:
**`createAccessGroups` is redundant before `syncAccessGroups`**
`syncAccessGroups` already upserts every group from the config in its step 1, so the preceding `createAccessGroups` call performs duplicate lookups for every configured group. Removing it avoids the unnecessary round-trips.
How can I resolve this? If you propose a fix, please make it concise.
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.
ConfigModule
loadcallback reads and parses the access config withfs.readFileSync/JSON.parsewithout any error handling. If the file is missing or malformed, startup will throw a low-level ENOENT / JSON error that’s hard to diagnose. Consider validating existence and wrapping parse errors to throw a clearer message (and optionally use the existingenv.ACCESS_CONFIG_PATHgetter for consistency).