@@ -3,7 +3,7 @@ import { z } from 'zod';
33
44import { AuditAction , AuditTrailEvents } from '../entities/AuditTrail' ;
55import { ParticipantType } from '../entities/ParticipantType' ;
6- import { UserJobFunction } from '../entities/User' ;
6+ import { User , UserJobFunction } from '../entities/User' ;
77import { getUserRoleById , UserRoleId } from '../entities/UserRole' ;
88import { UserToParticipantRole } from '../entities/UserToParticipantRole' ;
99import { getTraceId } from '../helpers/loggingHelpers' ;
@@ -142,4 +142,24 @@ export class UserService {
142142 } ) ;
143143 } ) ;
144144 }
145+
146+ public async updateUserLock ( req : UserParticipantRequest , userId : number , isLocked : boolean ) {
147+ const requestingUser = await findUserByEmail ( req . auth ?. payload . email as string ) ;
148+ const updatedUser = await User . query ( ) . where ( 'id' , userId ) . first ( ) ;
149+ const traceId = getTraceId ( req ) ;
150+
151+ const auditTrailInsertObject = constructAuditTrailObject (
152+ requestingUser ! ,
153+ AuditTrailEvents . ChangeUserLock ,
154+ {
155+ action : AuditAction . Update ,
156+ email : updatedUser ?. email ,
157+ locked : isLocked ,
158+ }
159+ ) ;
160+
161+ await performAsyncOperationWithAuditTrail ( auditTrailInsertObject , traceId , async ( ) => {
162+ await User . query ( ) . where ( 'id' , userId ) . update ( { locked : isLocked } ) ;
163+ } ) ;
164+ }
145165}
0 commit comments