@@ -64,6 +64,8 @@ export const ACTIVATION_OTP_EXPIRY_SECONDS = 24 * 60 * 60; // 24 hours
6464export const ACTIVATION_OTP_LENGTH = 6 ;
6565const OTP_ACTIVATION_MODE = 1 ;
6666const ACTIVATION_OTP_EXPIRY_MINUTES = 24 * 60 ;
67+ const WIPRO_SSO_PROVIDER = 'wipro-adfs' ;
68+ const WIPRO_ALL_GROUP_NAME = 'Wipro - All' ;
6769
6870@Injectable ( )
6971export class UserService {
@@ -828,6 +830,15 @@ export class UserService {
828830
829831 // add user to initial groups
830832 await this . addUserToDefaultGroups ( prisma , nextUserId ) ;
833+ if (
834+ userParams . profile ?. provider ?. toLowerCase ( ) === WIPRO_SSO_PROVIDER
835+ ) {
836+ await this . addUserToGroupByDescription (
837+ prisma ,
838+ nextUserId ,
839+ WIPRO_ALL_GROUP_NAME ,
840+ ) ;
841+ }
831842
832843 return createdUser ;
833844 } ) ;
@@ -2392,6 +2403,34 @@ export class UserService {
23922403 }
23932404 }
23942405
2406+ private async addUserToGroupByDescription (
2407+ prisma : any ,
2408+ userId : number ,
2409+ groupName : string ,
2410+ ) {
2411+ try {
2412+ const groupRecord = await prisma . security_groups . findFirst ( {
2413+ where : { description : groupName } ,
2414+ } ) ;
2415+ if ( ! groupRecord ) {
2416+ this . logger . warn (
2417+ `Group '${ groupName } ' not found when assigning user ${ userId } .` ,
2418+ ) ;
2419+ return ;
2420+ }
2421+ await this . addUserToGroup (
2422+ prisma ,
2423+ userId ,
2424+ Number ( groupRecord . group_id ) ,
2425+ ) ;
2426+ } catch ( error ) {
2427+ this . logger . error (
2428+ `Unable to resolve group '${ groupName } ' for user ${ userId } ` ,
2429+ error ,
2430+ ) ;
2431+ }
2432+ }
2433+
23952434 /**
23962435 * Add user to group.
23972436 * @param prisma Prisma client
0 commit comments