@@ -65,11 +65,11 @@ export class AuthorizationService {
6565 */
6666 async getUserContext (
6767 userId : string ,
68- organizationId : string
68+ organizationId : string ,
6969 ) : Promise < UserContext > {
7070 try {
7171 console . log (
72- `Checking user context for userId: ${ userId } , organizationId: ${ organizationId } `
72+ `Checking user context for userId: ${ userId } , organizationId: ${ organizationId } ` ,
7373 ) ;
7474
7575 // Get user's organization role
@@ -79,16 +79,16 @@ export class AuthorizationService {
7979 . where (
8080 and (
8181 eq ( userOrganization . userId , userId ) ,
82- eq ( userOrganization . organizationId , organizationId )
83- )
82+ eq ( userOrganization . organizationId , organizationId ) ,
83+ ) ,
8484 )
8585 . limit ( 1 ) ;
8686
8787 console . log ( `User org result:` , userOrg ) ;
8888
8989 if ( ! userOrg ) {
9090 console . log (
91- `User ${ userId } not found in organization ${ organizationId } `
91+ `User ${ userId } not found in organization ${ organizationId } ` ,
9292 ) ;
9393 throw new ApiError ( "User not found in organization" , 403 ) ;
9494 }
@@ -113,17 +113,17 @@ export class AuthorizationService {
113113 */
114114 async getProjectContext (
115115 projectId : string ,
116- organizationId ?: string
116+ organizationId ?: string ,
117117 ) : Promise < ProjectContext > {
118118 try {
119119 console . log (
120- `[AUTHZ] Getting project context for projectId: ${ projectId } , organizationId: ${ organizationId } `
120+ `[AUTHZ] Getting project context for projectId: ${ projectId } , organizationId: ${ organizationId } ` ,
121121 ) ;
122122
123123 const whereConditions = organizationId
124124 ? and (
125125 eq ( project . id , projectId ) ,
126- eq ( project . organizationId , organizationId )
126+ eq ( project . organizationId , organizationId ) ,
127127 )
128128 : eq ( project . id , projectId ) ;
129129
@@ -142,12 +142,12 @@ export class AuthorizationService {
142142 name : projectData . name ,
143143 visibility : projectData . visibility ,
144144 }
145- : "null"
145+ : "null" ,
146146 ) ;
147147
148148 if ( ! projectData ) {
149149 console . log (
150- `[AUTHZ] Project not found for projectId: ${ projectId } , organizationId: ${ organizationId } `
150+ `[AUTHZ] Project not found for projectId: ${ projectId } , organizationId: ${ organizationId } ` ,
151151 ) ;
152152 throw new ApiError ( "Project not found" , 404 ) ;
153153 }
@@ -171,22 +171,22 @@ export class AuthorizationService {
171171 userId : string ,
172172 projectId : string ,
173173 action : Permission ,
174- organizationId ?: string
174+ organizationId ?: string ,
175175 ) : Promise < boolean > {
176176 try {
177177 const projectContext = await this . getProjectContext (
178178 projectId ,
179- organizationId
179+ organizationId ,
180180 ) ;
181181 const userContext = await this . getUserContext (
182182 userId ,
183- projectContext . organizationId
183+ projectContext . organizationId ,
184184 ) ;
185185
186186 // Check organization-level permissions
187187 const orgPermission = this . checkOrganizationPermission (
188188 userContext . roles [ 0 ] || "" ,
189- action
189+ action ,
190190 ) ;
191191
192192 if ( orgPermission ) {
@@ -196,7 +196,7 @@ export class AuthorizationService {
196196 // Check project-level permissions
197197 const projectPermission = this . checkProjectPermission (
198198 userContext . roles [ 0 ] || "" ,
199- action
199+ action ,
200200 ) ;
201201
202202 return projectPermission ;
@@ -212,16 +212,16 @@ export class AuthorizationService {
212212 async canAccessOrganization (
213213 userId : string ,
214214 organizationId : string ,
215- action : Permission
215+ action : Permission ,
216216 ) : Promise < boolean > {
217217 try {
218218 console . log (
219- `Checking organization access for userId: ${ userId } , organizationId: ${ organizationId } , action: ${ action } `
219+ `Checking organization access for userId: ${ userId } , organizationId: ${ organizationId } , action: ${ action } ` ,
220220 ) ;
221221 const userContext = await this . getUserContext ( userId , organizationId ) ;
222222 const hasPermission = this . checkOrganizationPermission (
223223 userContext . roles [ 0 ] || "" ,
224- action
224+ action ,
225225 ) ;
226226 console . log ( `Organization access result: ${ hasPermission } ` ) ;
227227 return hasPermission ;
@@ -237,23 +237,23 @@ export class AuthorizationService {
237237 async canViewProject (
238238 userId : string ,
239239 projectId : string ,
240- organizationId ?: string
240+ organizationId ?: string ,
241241 ) : Promise < boolean > {
242242 try {
243243 const projectContext = await this . getProjectContext (
244244 projectId ,
245- organizationId
245+ organizationId ,
246246 ) ;
247247 const userContext = await this . getUserContext (
248248 userId ,
249- projectContext . organizationId
249+ projectContext . organizationId ,
250250 ) ;
251251
252252 // Check if user has organization access
253253 const hasOrgAccess = await this . canAccessOrganization (
254254 userId ,
255255 projectContext . organizationId ,
256- "read"
256+ "read" ,
257257 ) ;
258258
259259 if ( ! hasOrgAccess ) {
@@ -293,8 +293,8 @@ export class AuthorizationService {
293293 . where (
294294 and (
295295 eq ( userProject . userId , userId ) ,
296- eq ( userProject . projectId , projectId )
297- )
296+ eq ( userProject . projectId , projectId ) ,
297+ ) ,
298298 )
299299 . limit ( 1 ) ;
300300
@@ -325,7 +325,7 @@ export class AuthorizationService {
325325 if ( role in AuthorizationService . PROJECT_PERMISSIONS ) {
326326 const projectRole = role as ProjectRole ;
327327 return AuthorizationService . PROJECT_PERMISSIONS [ projectRole ] . map (
328- ( p ) => `project:${ p } `
328+ ( p ) => `project:${ p } ` ,
329329 ) ;
330330 }
331331
@@ -336,7 +336,7 @@ export class AuthorizationService {
336336 * Get project permissions for organization roles
337337 */
338338 private getProjectPermissionsForOrgRole (
339- orgRole : OrganizationRole
339+ orgRole : OrganizationRole ,
340340 ) : Permission [ ] {
341341 switch ( orgRole ) {
342342 case "OWNER" :
@@ -355,7 +355,7 @@ export class AuthorizationService {
355355 */
356356 private checkOrganizationPermission (
357357 role : string ,
358- action : Permission
358+ action : Permission ,
359359 ) : boolean {
360360 const permissions =
361361 AuthorizationService . ORGANIZATION_PERMISSIONS [ role as OrganizationRole ] ||
@@ -378,13 +378,13 @@ export class AuthorizationService {
378378 async removeUserRoles (
379379 userId : string ,
380380 organizationId ?: string ,
381- projectId ?: string
381+ projectId ?: string ,
382382 ) : Promise < void > {
383383 try {
384384 if ( organizationId ) {
385385 // Remove organization role
386386 console . log (
387- `Removing user ${ userId } from organization ${ organizationId } `
387+ `Removing user ${ userId } from organization ${ organizationId } ` ,
388388 ) ;
389389 }
390390 if ( projectId ) {
0 commit comments